Plot a normal figure and animatedline together onthe same figure
15 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone,
I have a question about how to plot a regular figure (using plot or plot3) and animated lines (using animatedline and addpoints) in the same figure.
I want also to record a video of the entire figure. Can I do that with regular way of getfram and VideoWriter?
Here is an example
t=0:0.01:10;
x=cos(t);
y=sin(t);
z=t;
h=animatedline('Color','r');
k=animatedline('Color','b');
view(3)
for i=1:length(t)
addpoints(h,x(i),y(i),z(i));
addpoints(h,0.5*x(i),0.5*y(i),z(i));
% I want also to plot the following in the same figure
plot3(x,y,z) % I want the graph to apear in full in the begining not as an animated line
end
Can anyone help me with that?
Thank you
0 件のコメント
採用された回答
dpb
2021 年 1 月 7 日
編集済み: dpb
2021 年 1 月 8 日
...
% I want also to plot the following in the same figure
% I want the graph to apear in full in the begining not as an animated line
% then plot it first, if that is what is desired
plot3(x,y,z)
view(3)
% then must set hold on to add to an axes or will clear existing stuff
hold on
h=animatedline('Color','r');
for i=1:length(t)
addpoints(h,x(i),y(i),z(i));
addpoints(h,0.5*x(i),0.5*y(i),z(i));
pause(0.01)
end
This fills the area between the outer and inner lines; not clear to me why it appears to be solid surface. If only add the inner points alone, then get the two lines, but the outer one isn't traced as one presumes is the intended effect.
ADDENDUM:
The solid comes from using the same animated line handle for both...since the two calls alternate inner/outer positions, the lines are drawn back and forth between the two. They're close enough together to give the illusion of a surface which is, at first, confusing as to what one is seeing.
Not sure what the intended look really is, but
h=animatedline('Color','r');
k=animatedline('Color','r');
for i=1:length(t)
addpoints(h,x(i),y(i),z(i));
addpoints(k,0.5*x(i),0.5*y(i),z(i));
pause(0.01)
end
gives the two lines, one retracing original curve and the inner at half diameter.
5 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Animation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!