how to plot cell array continuously as line

1 回表示 (過去 30 日間)
bernout breyer
bernout breyer 2021 年 8 月 17 日
コメント済み: darova 2021 年 8 月 19 日
Hi @ all
I would like to plot a cell array countinusly, as line, while the figure keeps the old value, how to do this in an efficient way?
following proceeding
  1. at first I get a cell array containg int16 values already (from former step) => A = cell(1:20)
  2. now I would like to plot those values and connecting values as line.
  3. after finishing for-loop, figure and its values shall remain.
  4. I get new values in A = cell(1:20)
  5. I would like to add those values to the plot, so that the new value is connected as line to former value A21(former) to A1(new) the same for y-axixs.
  6. remain figure and get new values in A and add those values... and so on...........
for c=1:20
y = A{c};
plot(x,y);
x=x+1;
hold on
end

回答 (1 件)

David Hill
David Hill 2021 年 8 月 17 日
y = cell2mat(A(1:20));
plot(1:numel(y),y);
  2 件のコメント
bernout breyer
bernout breyer 2021 年 8 月 18 日
編集済み: bernout breyer 2021 年 8 月 18 日

Thanks for fast response

For plotting one array it works well but how can I plot continously so that I get only one line

For instance, with this code I get 100 lines in one figure, but I would like to have one line which continues extends when cell array gets updated

for B=1:10

S{1}= 1+B;

S{2}= 2+B;

S{3}= 3+B;

S{4}= 4+B;

S{5}= 5+B;

S{6}= 6+B;

S{7}= 7+B;

S{8}= 9+B;

S{9}= 11+B;

S{10}= 13+B;

    y = cell2mat(S(1:10));
    plot(1:numel(y),y);
    hold on

end

darova
darova 2021 年 8 月 19 日
try
plot(1:numel(y),y(:))

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by