clc
clear
p=[36,46,56,76,86];
x=linspace(5,20,200);
y=linspace(65,175,200);
[xx,yy]=meshgrid(x,y);
figure
hold on
for i=1:length(p)
zz=xx/(xx+p(i))yy;
surface(xx,yy,zz);
shading flat
end
xlabel('x'),ylabel('y'),zlabel('z');
legend('36','46','56','76','86')
view(73,30)%s视角,具体看帮助
hold off
点菜单上面旋转视角,区别更明显
A=[1486,3059,01;2121,4041,01;2570,3959,01;3439,4396,01;4505,3012,01;3402,1604,01;2570,2065,01;2150,1970,01;
1794,3059,02;2121,3615,02;2570,3473,02;3421,4160,02;
4271,3036,02;3411,1876,02;2561,2562,02;2179,2420,02;
2757,3024,03;3439,3970,03;4084,3036,03;3402,2077,03;
2879,3036,04;3421,3793,04;3953,3036,04;3402,2219,04;
3000,3047,05;3430,3639,05;3822,3012,05;3411,2385,05;
3103,3012,06;3430,3462,06;3710,3036,06;3402,2562,06;
3224,3047,07;3411,3260,07;3542,3024,07;3393,2763,07];
x=A(:,1);y=A(:,2);z=A(:,3);
scatter(x,y,5,z)%散点图
figure
[X,Y,Z]=griddata(x,y,z,linspace(1486,4271)',linspace(1604,4276),'v4');%插值
pcolor(X,Y,Z);shading interp%伪彩色图
figure,contourf(X,Y,Z) %等高线图
figure,surf(X,Y,Z)%三维曲面
1
首先,打开MATLAB
2
1、点击“File” 2、选择“New” 3、点击“Script”
3
调用surf(得到含有等高线的三维曲面图)来绘制三维曲面图,调用格式如下:
surf(x,y,z,’PropertyName’,’PropertyValue’)
调用该函数对应m文件如下:
t=-2:01:2;
[x,y] =meshgrid(t);%%表示区域网格控制,目地是为了让x,y形成格点矩阵%%
z=5x^2+8y^3;
surf(x,y,z);
%%设置三维曲面x轴,y轴,z轴,标题对应内容及三个坐标轴的取值范围%%
xlabel('X');
ylabel('Y');
zlabel('Z');
title('surf三维曲面图');
axis([-25 25 -25 25 -5 25]);
4
点击这个绿色的按钮,如图
5
此时,三维曲面就画好了
X(1)=
29pi/180:05pi/180:39pi/180;
X(2)
=
62pi/180:05pi/180:75pi/180;
[Y1,Y2]
=
meshgrid(X(1),X(2));
%
生成画曲面需要的格点
Z
=
f(Y1,Y2);
%
计算格点对应的函数值,如果还有关于alpha取平均这件事,你是可以写在函数f内部进行
surf(Y1,Y2,Z)
%
画图
shading
interp
%
surf画图一般是有格线,如果觉得看着不舒服,这句是用来去掉格线,你可以根据需要选择使用
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)