plot3 Not Animating with the Loop (Drawnow is already added)
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Laurel Castillo
el 12 de Dic. de 2018
Comentada: Laurel Castillo
el 20 de Dic. de 2018
The 3D line is drawn with the mtm_x matrix set (3*2*100). In each loop, a set of 3*2 matrix is used to update the values of the line.
I checked that the values of Tip0 and TipX are updating. But the line stays in the initial position. (I've varied the loop no., but the line just stays there......)
Any suggestion?
mtm_x = mtm_x(:,:,1:100); % mtm_x is imported and become a 3*2*100 double
nt = length(mtm_x); % nt = 100
s=0.25;
figure(2);
grid on;
view(3);
for i = 1:nt
cla;
tip_x = mtm_x(:,:,i); % the 3D line is updated with i-th value set. e.g. for i=1, the first 3*2 matrix is used
%tip
TipO = tip_x(1:3,2);
TipX = tip_x(1:3,1).*s;
plot3([TipO(1) TipX(1)+TipO(1)], [TipO(2) TipX(2)+TipO(2)], [TipO(3) TipX(3)+TipO(3)], 'color', 'r', 'linewidth', 3);
hold on
axis([-0.5 0.5 -0.5 0.5 -0.5 0.5]);
drawnow;
end
Thanks!
3 comentarios
Jan
el 12 de Dic. de 2018
@Aqutris: :-) It will be hard to see a delay of a millisecond, when the monitor is updated with 60Hz. A longer pause would be useful.
Respuesta aceptada
Jan
el 12 de Dic. de 2018
Editada: Jan
el 12 de Dic. de 2018
mtm_x = rand(3,2,100); % mtm_x is imported and become a 3*2*100 double
nt = size(mtm_x, 3); % do not rely on LENGTH
s = 0.25;
Lim = [0, 1];
axesH = axes('XLim', Lim, 'YLim', Lim, 'ZLim', Lim, ...
'NextPlot', 'add');
grid on;
view(3);
for i = 1:nt
tip_x = mtm_x(:,:,i);
TipO = tip_x(1:3,2);
TipX = tip_x(1:3,1) .* s;
plot3(axesH, ...
[TipO(1) TipX(1)+TipO(1)], ...
[TipO(2) TipX(2)+TipO(2)], ...
[TipO(3) TipX(3)+TipO(3)], ...
'color', 'r', 'linewidth', 3);
drawnow;
end
This is a cleaned version without the cla . I can see a bunch of lines. So what exactly is the problem?
Where do you try to display this? I do not see the intermediate images in Matlab online.
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!