用符号变量绘制函数图象

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

用符号变量绘制函数图象

syms t;

y1=sin(t);

y2=cos(t);

y3=tan(t);

y4=cot(t);

y5=sec(t);

y6=cos(t.^2+1);

y7=cos(2*t-1)+sin(t-pi/6);

y8=cos(t+pi/9+t.^2);

y9=sin(t/9+t.^3);

subplot(3,3,1);ezplot(y1);

subplot(3,3,2);ezplot(y2);

subplot(3,3,3);ezplot(y3);

subplot(3,3,4);ezplot(y4);

subplot(3,3,5);ezplot(y5);

subplot(3,3,6);ezplot(y6);

subplot(3,3,7);ezplot(y7);

subplot(3,3,8);ezplot(y8);

subplot(3,3,9);ezplot(y9);

程序中的subplot是用来实现绘制多图的函数,而ezplot则是绘图的命令函数程序运行的图像如下

程序略作改变,加上一些方格子

syms t;

y1=sin(t);

y2=cos(t);

y3=tan(t);

y4=cot(t);

y5=sec(t);

y6=cos(t.^2+1);

y7=cos(2*t-1)+sin(t-pi/6);

y8=cos(t+pi/9+t.^2);

y9=sin(t/9+t.^3);

subplot(3,3,1);ezplot(y1); grid on; subplot(3,3,2);ezplot(y2); grid on; subplot(3,3,3);ezplot(y3); grid on; subplot(3,3,4);ezplot(y4); grid on; subplot(3,3,5);ezplot(y5); grid on; subplot(3,3,6);ezplot(y6); grid on; subplot(3,3,7);ezplot(y7); grid on; subplot(3,3,8);ezplot(y8); grid on; subplot(3,3,9);ezplot(y9); grid on;

改为另一种方式绘图

%syms t;

t=0:0.001:10;

y1=sin(t);

y2=cos(t);

y3=tan(t);

y4=cot(t);

y5=sec(t);

y6=cos(t.^2+1);

y7=cos(2*t-1)+sin(t-pi/6);

y8=cos(t+pi/9+t.^2);

y9=sin(t/9+t.^3);

subplot(3,3,1);plot(y1); grid on; subplot(3,3,2);plot(y2); grid on; subplot(3,3,3);plot(y3); grid on; subplot(3,3,4);plot(y4); grid on;

subplot(3,3,5);plot(y5); grid on;

subplot(3,3,6);plot(y6); grid on;

subplot(3,3,7);plot(y7); grid on;

subplot(3,3,8);plot(y8); grid on;

subplot(3,3,9);plot(y9); grid on;

%syms t;

t=0:0.001:10;

y1=sin(t);

y2=cos(t);

y3=tan(t);

y4=cot(t);

y5=sec(t);

y6=cos(t.^2+1);

y7=cos(2*t-1)+sin(t-pi/6);

y8=cos(t+pi/9+t.^2);

y9=sin(t/9+t.^3);

subplot(2,2,1);plot(t,y1,t,y2); grid on;

subplot(2,2,2);plot(t,y3,t,y4,t,y5,t,y6,t,y7);grid on; figure

plot(t,y8,t,y9); grid on;

title('三角函数图像')

用figure命令添加的图像如下

%syms t;

t=0:0.001:10;

y1=sin(t);

y2=cos(t);

y3=tan(t);

y4=cot(t);

y5=sec(t);

y6=cos(t.^2+1);

y7=cos(2*t-1)+sin(t-pi/6);

y8=cos(t+pi/9+t.^2);

y9=sin(t/9+t.^3);

figure

plot(t,y1,t,y2); grid on;

figure

plot(t,y3,t,y4,t,y5,t,y6,t,y7);grid on;

figure

plot(t,y8,t,y9); grid on;

title('三角函数图像')

相关文档
最新文档