Errors while using animated fplot3

1 visualización (últimos 30 días)
Oscar García
Oscar García el 5 de Abr. de 2017
Respondida: Walter Roberson el 6 de Abr. de 2017
Hi, I want to do an animation of rotating 3d parametric curves. I tried with fplot3 and the first example of this page https://es.mathworks.com/help/matlab/ref/hgtransform.html. But I can only plot a graph at a time. My code is below, first plot is a helix and second one a circle, if use both i get this error
Error using matlab.graphics.function.ParameterizedFunctionLine/set Invalid or deleted object.
Error in untitled3 (line 17) set(h,'Parent',t)
¿What I am doing wrong?
ax = axes('XLim',[-1.5 1.5],'YLim',[-1.5 1.5],'ZLim',[-1.5 1.5]);
view(3)
grid on
[x,y,z] = cylinder([.2 0]);
xt = @(t) 0.75*sin(t);
yt = @(t) 0.75*cos(t);
zt = @(t) t;
ht = @(t) 0;
h(1) = fplot3(xt,yt,zt,[-pi pi]);
%h(2) = fplot3(ht,yt,xt,[-pi pi]);
t = hgtransform('Parent',ax);
set(h,'Parent',t)
Rz = eye(4);
for r = 0:.1:2*pi
Rz = makehgtform('zrotate',r);
set(t,'Matrix',Rz)
pause(0.1);
drawnow
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Abr. de 2017
hold(ax, 'on')
After the axes call. It needs to be before the fplot3 call or else the fplot3 will erase the axes including getting rid of the grid and view

Más respuestas (0)

Categorías

Más información sobre Animation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by