フィルターのクリア

If for loop repeated itself many times, can I plot what calculated inside for loop in ONE CURVE ?

1 回表示 (過去 30 日間)
I tried to plot " x " via putting the plot inside for loop I got the plot of " x " from 1 : 20, But when the for loop repeated itself the x is plotted again from 1: 20 as second curve, while I want to let the first curve continoue in plotting the " x " even if the for loop ended and repeat itself.
Now, my question, can I plot " x " that calculated inside for loop that repeated itself more than one time in ONE CURVE,for example if for loop repeated itself two times , I want the plot show me one curve from 1 up to 40 ?
Thanks in advance
while 1
for i=1:20
x(i)=something
end
plot(x,i)
end

採用された回答

Walter Roberson
Walter Roberson 2022 年 7 月 31 日
I suggest you use animatedline() and addpoints() . You would need to keep track of your independent coordinate, such as
L = animatedline();
N = 20;
start = 1;
while 1
for i = 1 : N;
x(i) = something;
end
t = start : start + N - 1;
addpoints(t, x);
drawnow();
start = start + N;
end
  1 件のコメント
omar th
omar th 2022 年 8 月 2 日
First thank you for your reply, but this way didn't work, I think due to there is another calculations related to x out of while loop. Is there another way ?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by