Errors while using animated fplot3
1 view (last 30 days)
Show older comments
Oscar García
on 5 Apr 2017
Answered: Walter Roberson
on 6 Apr 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
0 Comments
Accepted Answer
Walter Roberson
on 6 Apr 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
0 Comments
More Answers (0)
See Also
Categories
Find more on Animation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!