Errors while using animated fplot3

조회 수: 2 (최근 30일)
Oscar García
Oscar García 2017년 4월 5일
답변: Walter Roberson 2017년 4월 6일
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