matlab中要求画几条不同的曲线 用不同的颜色 加标题 在线等!

y1=sin(t);
y2=cos(t);
y3=tan(t);
plot(t,y1,'r-';t,y2,'g';t,y3,'k');
legend('Vdc1','Vdc2');
grid on;hold on;
title('Vdc_PN');

报错了。。我也不会这个 怎么搞?
在线等!

原因:

    plot(t,y1,'r-';t,y2,'g';t,y3,'k')这里面出现了分号(;),应该改成逗号。

    由于tan会出现无穷大,所以图要分开画。

    没有定义t的取值范围

程序改成如下:

t=-2*pi:0.01:2*pi;
y1=sin(t);
y2=cos(t);
y3=tan(t);
subplot(211)
plot(t,y1,'r-',t,y2,'g');
legend('sin(t)','cos(t)');
grid on;
title('Vdc_PN');
subplot(212)
ezplot('tan(t)')%由于tan会出现无穷大,所以分开画
grid on

结果:

追问

瓦萨。。。。
谢谢了!!

温馨提示:内容为网友见解,仅供参考
第1个回答  2013-06-02
错了,根据运行提示修改就可以!
第2个回答  2013-06-02
D
相似回答