matalab三维画图

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_23301703/article/details/89374308
%matlab三维网格图2种方式

%1. plot3 三维曲线图
close all;clc;
z=linspace(0,10,101);% 生成0-10之间101个线性点

x=sin(z);y=cos(z);

plot3(x,y,z,'g','LineWidth',2) %plot3坐标 
                               %    
hold on 
plot3(x,y,z,'p','MarkerSize',10) %在第一个画图基础上 添加 point

效果 注意对比 第一个plot3与第二个holdon后的plot3

第二种 matlab mesh matlab三维曲面图函数

%2. mesh三维网格图
%step1 确定x y 取值范围和取值间隔
clear;
x=1:0.1:10,y=1:0.1:10;
%step2 构成自变量采样“格点矩阵”
[X,Y]=meshgrid(x,y);
%step3 根据自变量X,Y来画出三维曲面Z
Z = sin(X).^2+cos(Y).^2;
mesh(X,Y,Z)
figure(2)
axis tight

猜你喜欢

转载自blog.csdn.net/qq_23301703/article/details/89374308
今日推荐