生成旋转面的matlab程序
今天做课件,需要一个生成旋转面的动画,就编了一个曲线 z=3*(y-2)^2 绕Z 轴旋转生成旋转面的程序,生成的动画见附件,希望对大家有点用。clear
clc
mov=avifile('xuanzhuanmian4.avi');
y=1:0.01:2;
z=3*(y-2).^2;
x=zeros(size(y));
r=y;
theta=;
n=length(theta);
plot3(x,y,z,'k','LineWidth',2);
hold on
quiver3(0,0,0,-1,0,0,3,'k','filled','LineWidth',2);
quiver3(0,0,0,0,-1,0,3,'k','filled','LineWidth',2);
quiver3(0,0,0,0,0,1,4,'k','filled','LineWidth',2);
text(0,-0.5,4.2,'Z')
text(0,-3.5,0.3,'Y')
text(-3.5,0,0.3,'X')
axis equal
axis([-2,2,-2,2,0,4])
axis off
for i=1:n-1
=meshgrid(r,linspace(theta(i),theta(i+1),10));
zz=repmat(z,10,1);
xx=rr.*cos(alpha1);
yy=rr.*sin(alpha1);
surf(xx,yy,zz);
shading interp
alpha(1)
drawnow;
pause(0.8)
f=getframe(gcf);
mov=addframe(mov,f);
end
hold off
mov=close(mov);
页:
[1]