how to make drawnow for this figure

10 次查看(过去 30 天)
Hi
How do i make my figure plot from this to its negative point, so the figure goes back and forward ( the red line on the uploaded figure) in an animated figure:
figure
plot3(x_coor,z_coor,y_coor,'k','HandleVisibility','off');
hold on;
plot3(Px_coor,Pz_coor,Py_coor,'r','HandleVisibility','off');
x_coor = [0 1 2 3 4 5
1 2 3 4 5 6]
y_coor = [0 0 0 0 0 0
0 0 0 0 0 0]
z_coor = [0 0 0 0 0 0
0 0 0 0 0 0]
Px_coor = [0 1 2 3 4 5
1 2 3 4 5 6]
Pz_coor = [0 0 0 0 0 0
0 0 0 0 0 0]
Py_coor = [0 0.0225501852619405 0.0827680826631456 0.169761552175099 0.273470524612610 0.385480815448938
0.0225501852619405 0.0827680826631456 0.169761552175099 0.273470524612610 0.385480815448938 0.500000000000000]

回答(1 个)

Devineni Aslesha
Devineni Aslesha 2020-3-24
To animate the red line shown in the attached figure, use the below code. Here, pause is used instead of draw to notice that the animation took place.
h = animatedline;
for t = 1:length(Px_coor)
addpoints(h,Px_coor(1,t),Pz_coor(1,t),Py_coor(1,t));
pause(0.5);
end
For more information, refer the following links.
  4 个评论
polo Mahmoud
polo Mahmoud 2020-3-26
Hi I wanted the red line go from 0.5 to -0.5 i the y-axis on the figure I uploaded. Such that it simulated the first modeshape of a canteliver beam
Devineni Aslesha
Devineni Aslesha 2020-3-26
Change the coordinates from the code below to move the red line from 0.5 to -0.5 in the y-axis.
x_coor = [0 1 2 3 4 5];
y_coor = [0 0 0 0 0 0];
z_coor = [0 0 0 0 0 0];
Px_coor = [0 1 2 3 4 5 5 4 3 2 1 0];
Pz_coor = [0 0 0 0 0 0 0 0 0 0 0 0];
Py_coor = [0 0.0225501852619405 0.0827680826631456 0.169761552175099 0.273470524612610 0.385480815448938 -0.385480815448938 -0.27347052461261 -0.169761552175099 -0.0827680826631456 -0.0225501852619405 0];
figure(1)
plot3(x_coor,z_coor,y_coor,'k','HandleVisibility','off');
hold on;
h = animatedline;
for t = 1:length(Px_coor)
addpoints(h,Px_coor(1,t),Pz_coor(1,t),Py_coor(1,t));
pause(0.8);
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by