フィルターのクリア

Can you change the color of new points without changing the color of an entire line?

6 ビュー (過去 30 日間)
Joseph Criniti
Joseph Criniti 2023 年 2 月 17 日
回答済み: Walter Roberson 2023 年 2 月 17 日
This code is designed to plot the motion of the earth traveling around the sun. Every year I would like the color of the new points to change but leave the rest of the points the color they were plotted in.
%Plot
animationTime = 20;
h = animatedline('color','r')
for i = 1:length(X(:,1))
addpoints(h,X(i,1),X(i,2),X(i,3));
pause(animationTime/length(X(:,1)));
if j > round(length(t)/(tspan(2)/years))
h.Color = [randi(100)/100 randi(100)/100 randi(100)/100];
j = 0;
end
j = j + 1;
end
tspan is the timespan for ode45. Its defined in terms of year and is then converted to seconds when fed into ode45. I understand why the existing code alters the entire line but is there a way to only effect new points. Thank you.

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 2 月 17 日
No. The underlying graphics object only stores a single line color, not one color per point or group of points. You would need to start a new animated line.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by