Errors while using animated fplot3

1 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2017-4-6
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

更多回答(0 个)

类别

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