数模实验作业2

1( 15分 )
绘制函数曲线,要求写出程序代码

(1)在区间[0:2π]均匀的取50个点,构成向量t;

(2)在同一窗口绘制曲线y1=sin(2*t-0.3); y2=3cos(t+0.5);要求y1曲线为红色点划线,标记点为圆圈;y2为蓝色虚线,标记点为星号.

t=0:2*pi/49:2*pi;
y1=sin(2*t-0.3); 
y2=3*cos(t+0.5);
plot(t,y1,'r-.o',t,y2,'b:*');

在这里插入图片描述
在这里插入图片描述

t=0:0.5:10;
y1=exp(-0.1*t);
y2=exp(-0.2*t);
y3=exp(-0.5*t);
plot(t,y1,'b-o',t,y2,'r:*',t,y3,'g-.')%画图
title('y=exp(-a*t)');%添加标题
legend('a=0.1','a=0.2','a=0.5');%添加图例
xlabel('t');
ylabel('y=exp(-a*t)')

在这里插入图片描述
在这里插入图片描述

[x,y]=meshgrid([-2:.2:2]);
z=x.*exp(-x.^2-y.^2);
mesh(x,y,z);
subplot(2,2,1),plot3(x,y,z);
title('三维线图plot3(x,y,z)');
subplot(2,2,2),mesh(x,y,z);
title('网线图mesh(x,y,z)');
subplot(2,2,3),surf(x,y,z);
title('表面图surf(x,y,z)');
subplot(2,2,4),surf(x,y,z);
shading interp
title('带渲染效果的表面图surf(x,y,z),shading interp');

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_45745322/article/details/115003762
今日推荐