实验内容 |
实 验 步 骤、过 程
1.(1)
close;clc;clear;
figure()
x = 0:0.01:2*pi;
y1 = sin(x);
y2 = cos(x);
plot(x,y1,'r',x,y2,'g');
legend('sin(x)','cos(x)');
(2)
close;clc;clear;
figure()
subplot(1,2,1);
x = 0:0.01:2*pi;
y1 = sin(x);
plot(x,y1,'r');
title('y=sin(x)')
subplot(1,2,2);
x = 0:0.01:2*pi;
y2 = cos(x);
plot(x,y2,'g');
title('y=cos(x)')
2.
方法一:
close;clc;clear;
x = -2:0.01:2;
y1 = x.^2;
y2 = x.^3;
y3 = x.^4;
y4 = x.^5;
plot(x,y1,'r',x,y2,'g',x,y3,'m',x,y4,'b');
grid on
title('y=x^i(1=2,3,4,5)');
xlabel('x轴');
ylabel('y轴');
legend('x^2','x^3','x^4','x^5');
方法二:
close;clc;clear;
x = -2:0.01:2;
y1 = x.^2;
plot(x,y1,'r');
hold on
y2 = x.^3;
plot(x,y2,'g');
hold on
y3 = x.^4;
plot(x,y3,'m');
hold on
y4 = x.^5;
plot(x,y4,'b');
hold off
grid on
title('y=x^i(1=2,3,4,5)');
xlabel('x轴');
ylabel('y轴');
legend('x^2','x^3','x^4','x^5');
3.
close;clc;clear;
subplot(2,2,1);
x = -3:0.1:3;
y = 16 * exp(-x.^2);
plot(x,y,'r');
title('y=16e^(-x^2),x∈[-3,3]');
subplot(2,2,2);
x = -2:0.1:2;
u = x .* sqrt(4 - x .* x);
plot(x,u,'g',x,-u,'g');
title('y^2=x^2(4-x^2),x∈[-2,2]');
subplot(2,2,3);
x = 0:pi/50:2 * pi;
y = sin(2*x);
plot(x,y,'m');
title('y=sin(2θ),θ∈[-2,2π]');
subplot(2,2,4);
t = 0:pi/30:10 * pi;
x = sin(t);y = cos(t);z = t;
plot3(x,y,z);
xlabel('x');ylabel('y');zlabel('z');
title('x=sint,y=cost,z=t,t∈[0,10π];')
4.(1)
x1 = -10:0.5:10;
y1 = -10:0.5:10;
[x1,y1] = meshgrid(x1,y1);
v=sqrt(x1.^2+y1.^2)+eps %防止出现0/0
z1=sin(v)./v;
mesh(x1,y1,z1);
figure %产生一个新的图形窗口Figure2
surf(x1,y1,z1);
figure %Figure3
contour(x1,y1,z1);
figure %Figure4
ezsurf('z1',[-6,6,-6,6]);
figure %Figure5
ezmesh('z1',[-6,6,-6,6]);
figure %Figure6
ezcontour('z1',[-6,6,-6,6]);
(2)
x2 = -2:0.01:2;
y2 = -2:0.01:2;
[x2,y2] = meshgrid(x2,y2);
v=x2.^2+y2.^2
z2=2*x2./exp(v);
mesh(x2,y2,z2);
figure %产生一个新的图形窗口Figure2
surf(x2,y2,z2);
figure %Figure3
contour(x2,y2,z2);
figure %Figure4
ezsurf('z2',[-6,6,-6,6]);
figure %Figure5
ezmesh('z2',[-6,6,-6,6]);
figure %Figure6
ezcontour('z2',[-6,6,-6,6]);
5.
x = 0:0.05:25;
y1 = sin(x+cos(x+sin(x)));
y2 = 0.2*x+sin(x+cos(x+sin(x)));
plot(x,y1,'r:',x,y2,'b-');
ylim([-6,13])
title('周期函数和线性周期函数')
xlabel('x从0到8π');
ylabel('y纵轴');
text(11.9317,3.2858,'←周期函数G(x)在点11.9317的值为:3.2858');
text(12.15,0.2622,'←线性周期函数F(x)')
legend('sin(x+cos(x+sin(x)))','0.2x+sin(x+cos(x+sin(x)))');
答案供参考,如有错误请自行改正,本人只是随意分享之前的作业,代码均来源于网络+个人稍微修改,认为有用可参考哈~