How to plot and fit a simple cell

1 回表示 (過去 30 日間)
Carver Nabb
Carver Nabb 2019 年 1 月 3 日
編集済み: Bob Thompson 2019 年 1 月 3 日
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 Center および File ExchangeExploration and Visualization についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by