2.2.1曲线图

% 曲线
figure(1)   % 建立幕布
x_arr = [0:0.1:20*pi];
y_arr = exp(-0.1*x_arr).*cos(x_arr);
plot(x_arr,y_arr)

% 三维曲线
figure(2)
z_arr = x_arr .* sin(x_arr);
plot3(x_arr,y_arr,z_arr)

% 三维曲面
figure(3)
x = [-2:0.1:2];
y = x;
[x,y] = meshgrid(x,y)    %网格化自变量
z = x .* exp(-x.^2-y.^2);
surf(x,y,z)               % 三维图(已填充颜色)

figure(4)
mesh(x,y,z)              % 三维图(无颜色网格)
figure(5)
contour3(x,y,z)          % 三维等高线    

% 子图subplot
figure(6)
subplot(2,2,1)  % 放在2×2区的1号区
plot(x_arr,y_arr)
subplot(2,2,2)  % 放在2×2区的2号区
plot(x_arr,y_arr)
subplot(2,1,2)  % 放在2行1列的2号区
plot(x_arr,y_arr)

输出结果:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_43328166/article/details/108546898