how to make drawnow for this figure

10 visualizzazioni (ultimi 30 giorni)
polo Mahmoud
polo Mahmoud il 18 Mar 2020
Commentato: Devineni Aslesha il 26 Mar 2020
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]

Risposte (1)

Devineni Aslesha
Devineni Aslesha il 24 Mar 2020
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 Commenti
polo Mahmoud
polo Mahmoud il 26 Mar 2020
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 il 26 Mar 2020
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

Accedi per commentare.

Categorie

Scopri di più su Animation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by