zhoujia 发表于 2010-3-29 11:13:45

一个你可能常遇到的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 循环不起作用,望各位说说解决的办法,谢谢。

wsz310 发表于 2010-3-29 15:02:47

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个图。

wsz310 发表于 2010-3-29 15:10:04

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个图

zhoujia 发表于 2010-3-29 18:47:53

非常感谢各位啦

zylpascal 发表于 2010-3-29 19:29:45

不错适合初学者 笑嘻嘻
页: [1]
查看完整版本: 一个你可能常遇到的matlab问题

招聘斑竹