example2
clf
ax = axes('XLim',[-2 1],'YLim',[-2 1],'ZLim',[-1 1]);
view(3); grid on; axis equal
[x y z] = cylinder([.3 0]);
h(1) = surface(x,y,z,'FaceColor','red');
h(2) = surface(x,y,-z,'FaceColor','green');
h(3) = surface(z,x,y,'FaceColor','blue');
h(4) = surface(-z,x,y,'FaceColor','cyan');
h(5) = surface(y,z,x,'FaceColor','magenta');
h(6) = surface(y,-z,x,'FaceColor','yellow');
t1 = hgtransform('Parent',ax);
t2 = hgtransform('Parent',ax);
set(gcf,'Renderer','opengl')
set(h,'Parent',t1)
h2 = copyobj(h,t2);
Txy = makehgtform('translate',[-1.5 -1.5 0]);
set(t2,'Matrix',Txy)
drawnow
mov = avifile('example2.avi');
for k = 60:6:1800
r = k*pi/180;
Rz = makehgtform('zrotate',r);
set(t1,'Matrix',Rz)
set(t2,'Matrix',Txy*inv(Rz)*eye(4))
drawnow
F = getframe(gcf);
mov = addframe(mov,F);
end
mov = close(mov);
Warning: Cannot locate Indeo5 compressor, using 'None' as the compression type.
See <a href="http://www.mathworks.com/support/solutions/data/1-4G50RI.html">Mathworks
Technical Solution 1-4G50RI</a> for more information.