[Matlab科学绘图]Matlab三维绘图总结

[Matlab科学绘图]Matlab三维绘图总结
主要对matlab三维绘图函数进⾏总结并展⽰⼀下绘图结果,重点不在函数解读,在于函数介绍,函数的具体使⽤可以查看matlab的help⽂档。
函数名说明
line,plot3,ezplot3绘制三维曲线
mesh,ezmesh绘制三维⽹状图
meshc,ezmeshc绘制带有等⾼线的三维⽹状图
meshz绘制带有“围裙”的⽹状图
surf,ezsurf绘制三维曲⾯图
surfc,ezsurfc绘制带有等⾼线的三维曲⾯图
surfl绘制带有光照的三维曲⾯图
surfnorm计算或者显⽰三维表⾯法向
contour3绘制三维等⾼线图
waterfall绘制带有⽔流效果的三维图
pcolor绘制以颜⾊表⽰⾼度的图形
1. line,plot3,ezplot3绘制三维曲线
t=linspace(0,pi,401); %⽣成图形窗⼝
xf=inline('sin(t*8)*2'); %⽣成内联函数
yf=inline('cos(t*8)*3');
s(1)= subplot(131);
%利⽤函数line绘制三维曲线
line(sin(t*8),cos(t*8),t);
s(2)=subplot(132);
%利⽤plot3绘制两条曲线
plot3(sin(t*8)/2,cos(t*8)/2,t,'k',sin(t*16),cos(t*16),t,'r:');
s(3)=subplot(133);
%根据符号表达式绘制三维曲线
ezplot3(xf,yf,inline('t'),[-3,3]);
axis equal;
%设置坐标轴视⾓
view(s(1),[-33,14]);
view(s(2),[-33,14]);
view(s(3),[44,62]);
[X,Y]=meshgrid(-2:0.2:2, -2:0.2:2);%⽣成坐标格⽹矩阵
Z=X.*exp(-X.^2-Y.^2);
subplot(131);mesh(X,Y,Z);%绘制⽹状图
xlabel('(a)','Fontsize',14,'Fontname','Times New Roman');
subplot(132);mesh(X,Y,Z,rand(size(Z)));%绘制随机彩⾊⽹状图
xlabel('(b)','Fontsize',14,'Fontname','Times New Roman');
subplot(133);mesh(X,Y,Z,2*ones(size(Z)),'EdgeColor','k');%绘制单⾊⽹状图xlabel('(c)','Fontsize',14,'Fontname','Times New Roman');
zfun=inline('sqrt(1-s^2-t^2)');%定义内联函数
xs=inline('cos(s)*cos(t)');
ys=inline('cos(s)*sin(t)');
zs=inline('sin(s)');
subplot(131);ezmesh(zfun,100);%绘制⽹状图并指明采样点数
xlabel('(a)','Fontsize',14,'Fontname','Times New Roman');
subplot(132);ezmesh(zfun,[-1,1],20);
xlabel('(b)','Fontsize',14,'Fontname','Times New Roman');王永庆的球童
subplot(133);ezmesh(xs,ys,zs,[-pi,pi],20);
xlabel('(c)','Fontsize',14,'Fontname','Times New Roman');
改变ezmesh绘制⽹状图的着⾊⽅案
xs=inline('cos(s)*cos(t)');
ys=inline('cos(s)*sin(t)');
zs=inline('sin(s)');
subplot(131);ezmesh(xs,ys,zs,[0,pi],16);
view([-39,56])
xlabel('(a)','Fontsize',14,'Fontname','Times New Roman'); subplot(132);ezmesh(xs,ys,zs,[0,pi],16);
view([-39,56])
S1=get(gca,'Children');
set(S1,'CData',rand(size(get(S1,'CData'))));%通过句柄对⽹状图着⾊xlabel('(b)','Fontsize',14,'Fontname','Times New Roman'); subplot(133);ezmesh(xs,ys,zs,[0,pi],16);
view([-39,56])
S1=get(gca,'Children');
radarsatset(S1,'EdgeColor','k');%通过句柄对⽹状图着⾊
xlabel('(c)','Fontsize',14,'Fontname','Times New Roman');
条子生5.meshc绘制带有等⾼线的⽹状图
[X,Y,Z]=peaks(30);%⽣成坐标数据
subplot(121),meshc(Z);%⽣成带等⾼线的⽹状图
xlabel('(a)','Fontsize',14,'Fontname','Times New Roman'); subplot(122),m=meshc(X,Y,Z,Z);
set(m(1),'EdgeColor','k');%通过句柄改变属性
xlabel('(b)','Fontsize',14,'Fontname','Times New Roman');
subplot(131),ezmeshc('imag(atan(x+i*y))',[-4,4]);
xlabel('(a)','Fontsize',14,'Fontname','Times New Roman'); subplot(132),ezmeshc('real(log(x+i*y))',[-4,4],30);
xlabel('(b)','Fontsize',14,'Fontname','Times New Roman'); S2=get(gca,'Children');set(S2(end),'EdgeColor','k'); subplot(133),ezmeshc('real(log(x+i*y))',[-4,4],'circ'); xlabel('(c)','Fontsize',14,'Fontname','Times New Roman');
[X,Y,Z]=peaks(30);%⽣成坐标数据
cs太平洋subplot(121),meshz(Z);%⽣成带"围裙"的⽹状图
xlabel('(a)','Fontsize',14,'Fontname','Times New Roman'); subplot(122),m=meshz(X,Y,Z,Z);
set(m(1),'EdgeColor','k');%通过句柄改变属性
xlabel('(b)','Fontsize',14,'Fontname','Times New Roman');
usb软驱
8.surf绘制三维曲⾯图
[x,y]=meshgrid(linspace(-3,3,31));%⽣成格⽹坐标
z=(x-y).*exp(-(x.^2+y.^2)/2);
subplot(121),surf(x,y,z);%绘制曲⾯图
xlabel('(a)','Fontsize',14,'Fontname','Times New Roman'); subplot(122),surf(x,y,z,'EdgeColor','flat');
xlabel('(b)','Fontsize',14,'Fontname','Times New Roman');
funx=inline('sin(s)*t');%定义数学表达式
funy=inline('cos(s)*t');
funz=inline('sinc(t)');
subplot(231),ezsurf(@(x,y) funz(x)*cos(y));%绘制曲⾯图
xlabel('(a)','Fontsize',14,'Fontname','Times New Roman');
subplot(232),ezsurf(@(x,y) sin(x*2)*sinc(y),[-pi,pi]);%绘制曲⾯图,并设定⽹格线属性xlabel('(b)','Fontsize',14,'Fontname','Times New Roman');
subplot(233),ezsurf(funx,funy,funz);%绘制曲⾯图,并设定⽹格线属性
xlabel('(c)','Fontsize',14,'Fontname','Times New Roman');
subplot(234),ezsurf(@(s,t) funx(s,t)*sin(t),@(s,t) funy(s,t)*cos(t^2),...
@(s,t) funz(t)*sinc(s),[-2,2]);%绘制曲⾯图,并设定⽹格线属性
xlabel('(d)','Fontsize',14,'Fontname','Times New Roman');
subplot(235),ezsurf(@(s,t) funz(t)*sin(s),30);%绘制曲⾯图,并设定⽹格线属性
xlabel('(e)','Fontsize',14,'Fontname','Times New Roman');
subplot(236),ezsurf(@(s,t) exp(-[s^2+t^2]),[-2,2],2,'circ');%绘制曲⾯图,并设定⽹格线属性xlabel('(f)','Fontsize',14,'Fontname','Times New Roman');
经营儿童图书馆10.surfc绘制带有等⾼线的曲⾯

本文发布于:2024-09-25 02:22:29,感谢您对本站的认可!

本文链接:https://www.17tex.com/xueshu/90888.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:绘制   函数   状图   坐标   绘图   带有   属性   围裙
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议