How to plot and fit a simple cell

3 次查看(过去 30 天)
I have a 1x220 cell (a) with each element being a 1x4 cell. I would like to plot the four elements of the 1x4 cells on the y axis, with the x axis simply being 1 through 4. I would then like to find the line of best fit (m of y=mx+b) for each of the 220 plots. Within the 1x4 cells is numerical data, one number as each element.
I currently have something along the lines of:
counter = 1:4;
for i = 1:220
plot(counter, a(i));
fit(counter, a(i), 'poly1');
end
But the plot does not seem to work. I receive an error that says "Invalid data argument".
If finding the slope (m) is doable without having to plot I would prefer to do that though I do not know how.
  1 个评论
Bob Thompson
Bob Thompson 2019-1-3
编辑:Bob Thompson 2019-1-3
You might find it easier of you bring the data out into a 4x220 or 220x4 array first (look up cell2mat). Then it can just be a double and should smooth things quite a bit. It would also be possible to add another column or row with the numbers 1:4 in them.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by