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.
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!