matlab 如何将多个结果放在一个图里显示,进行比较

程序很长,是中间的参数发生改变,然后不知道hold on 和plot怎么加了~~
theta=32*pi/60/180;%入射偏角
x=[];
y=[];
z=[];
fai=0;
for theta=0:0.00013:32*pi/60/180
theta
S=[sin(theta)*cos(0),sin(theta)*sin(fai),cos(theta)
.....
xout(1)=[];
xout=[-fliplr(xout) xout];
n=[fliplr(n) n];

plot(xout,n,'-');
xlabel('r/m')
ylabel('n')
axis([-0.15 0.15 0 350000])
theta发生变化,图变化,想把不同的结果放在一个里面比较哈,谢谢指教哈!本身不是很富有,给5分啦!

可以将 plot() 放入for loop 里面, 然后 plot() 后面加 hold on。这样每一次进入for loop,先更新theta数值,再更新xout 数值,然后将更新后的xout 绘出。figure(1) 让每一次更新的图像都显示在同一个窗口中。加pause 可以在每一次运行完for 之后暂停程序。如下:

for theta=0:0.00013:32*pi/60/180
theta
S=[sin(theta)*cos(0),sin(theta)*sin(fai),cos(theta)
.....
xout(1)=[];
xout=[-fliplr(xout) xout];
n=[fliplr(n) n];

figure(1);
plot(xout,n,'-'); hold on;
xlabel('r/m');
ylabel('n');
axis([-0.15 0.15 0 350000]);

pause;
end
hold off;
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-03-10
在plot()前加hold on,或后面加hold on分别试试就知道了追问

前面还有其他图,我改变参数的时候是在过程中哦,还是搞不清~~~

相似回答