一个你可能常遇到的matlab问题
我的程序如下:% 绘制花瓣图
theta = -pi:0.01:pi;
rho(1,:) = 2*sin(5*theta).^2;
rho(2,:) = cos(10*theta).^3;
rho(3,:) = sin(theta).^2;
rho(4,:) = 5*cos(3.5*theta).^3;
for k =1:4 % 循环控制
polar(theta,rho(i,:)) % 绘制极坐标图
end
但上面程序运行结果却只有一个图行,好像 for ..... end 循环不起作用,望各位说说解决的办法,谢谢。 theta = -pi:0.01:pi;
rho(1,:) = 2*sin(5*theta).^2;
rho(2,:) = cos(10*theta).^3;
rho(3,:) = sin(theta).^2;
rho(4,:) = 5*cos(3.5*theta).^3;
for i =1:4 % 循环控制
subplot(2,2,i),
polar(theta,rho(i,:)) % 绘制极坐标图
end
这样可以出现4个图。 theta = -pi:0.01:pi;
rho(1,:) = 2*sin(5*theta).^2;
rho(2,:) = cos(10*theta).^3;
rho(3,:) = sin(theta).^2;
rho(4,:) = 5*cos(3.5*theta).^3;
for i =1:4 % 循环控制
figure
polar(theta,rho(i,:)) % 绘制极坐标图
end
这样也可以得到4个图 非常感谢各位啦 不错适合初学者 笑嘻嘻
页:
[1]