MATLAB入门及数学建模初步(第2次课).pptVIP

  • 6
  • 0
  • 约4.01千字
  • 约 12页
  • 2017-08-14 发布于北京
  • 举报
函数(内部函数和用户函数) 用户函数的集合 = TOOLBOX 工具箱的应用涵盖越来越多领域 Matlab强大的数据可视化能力 首先观察几个简单的绘图实例~ %空间中扭曲的矩阵 A=zeros(32); A(14:16,14:16)=ones(3);y=fft2(A);surf(abs(y)); %玲珑剔透球 [x,y,z]=sphere(30); surf(x,y,z); hold on; axis off ; shading interp; mesh(2*x,2*y,2*z); colormap(hot); hidden off ; axis equal; %hidden off 消隐函数 %鹦鹉螺 a=-0.2; b=0.5; c=0.1; [u,v]=meshgrid(linspace(0,2*pi,128)); x=(a*(1-v/(2*pi)).*(1+cos(u))+c).*cos(2*v); y=(a*(1-v/(2*pi)).*(1+cos(u))+c).*sin(2*v); z=b*v/(2*pi)+a*(1-v/(2*pi)).*sin(u); surf(x,y,z,y); shading interp; axis off; axis equal; view(-126,0);colormap(hsv(1024)); material shiny; lighting gouraud; lightangle(80, -40); lightangle(-90, 60); Matlab强大的数据可视化能力 MATLAB绘制较复杂动态图形(需7.0版本以上) Matlab强大的数据可视化能力 MATLAB绘制较复杂三维图形(试试axis off) DessineMoiUnB747(0,12 *pi/180,-5 *pi/180,15); %示范语句 Matlab基本绘图/控制指令一 figure(n) clf hold on/off grid on/off axis on/off axis equal axis square axis([x1 x2 y1 y2]) box on/off view hidden on/off zoom xon/yon xlabel(xstr) ylabel(ystr) title(tstr) legend(, ) text(x,y,str) text(3,5,sin({\omega}t+{\beta}))%希腊字母 举例1: x=-pi:pi/100:pi; y1=sin(x); y2=exp(x); plot(x,[y1;y2]); grid on; ylabel(test); legend(sin, exp); line([-4 4],[0 0],color,r); %画连接(-4,0)和(4,0)的线段X轴 举例2: x=-pi:pi/10:pi; plot(x,cos(x), -ro,x,sin(x), -b*); legend(cos,sin,2); text(2, cos(2),point) set(gcf,color,[1,1,1]); %将当前绘图窗口背景色设置为白色 Matlab基本绘图/控制指令二 plot(x,y,r-) plotyy(x1,y1,x2,y2) subplot(2,2,1) , 举例3: x=-2*pi:0.1:2*pi; plot(x,sin(1./x),-bs); hold on; plot(x,sin(tan(x))-tan(sin(x)),-ro,linewidth,2); fplot(fname,lims,tol,options) 自适应采样绘图函数,举例4: fplot(sin(1/x),[-2*pi, 2*pi],-ro) ; %线型 fplot(cos(tan(pi*x)),[ 0,1],1e-4); %精度 set(findobj(gca,type,line,color,b),linewidth,5); %粗细 ezplot(f, [a,b]) 隐函数绘图函数,举例5: ezplot(x^3+y^3-5*x*y+1/5); ezplot(8*cos(t),4*sqrt(2)*sin(t),[0,2*pi]); %区间 ezplot(x^2+y^2-5); hold on; ezplot(x*y-3*x+y-1); %交点 set(findobj(type,line),linestyle,--,color,r, li

文档评论(0)

1亿VIP精品文档

相关文档