1 / 16

实验一

实验一. 特殊函数与图形. 问题背景与实验目的. 问题背景和实验目的. 绘图是数学中的一种重要手段,借助图形,可以使抽象的对象得到明白 直观的体现 ,如函数的性质等。同时,借助直观的图形,使初学者更容易接受新知识,激发学习兴趣。. 本实验通过绘制一些 特殊函数的图形 ,一方面展示这些函数的特点属性,另一方面,就 Matlab 强大的作图功能作一个简单介绍。. p lot 举例. 例: 用 plot 在一个坐标系下绘制以下函数的图形,要求采用不同的颜色、线型和点标记. t=0:pi/20:2*pi; x=sin(t); y=cos(t);

kevyn-lucas
Download Presentation

实验一

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 实验一 特殊函数与图形

  2. 问题背景与实验目的 • 问题背景和实验目的 • 绘图是数学中的一种重要手段,借助图形,可以使抽象的对象得到明白直观的体现,如函数的性质等。同时,借助直观的图形,使初学者更容易接受新知识,激发学习兴趣。 • 本实验通过绘制一些特殊函数的图形,一方面展示这些函数的特点属性,另一方面,就 Matlab 强大的作图功能作一个简单介绍。

  3. plot 举例 例:用 plot在一个坐标系下绘制以下函数的图形,要求采用不同的颜色、线型和点标记 t=0:pi/20:2*pi; x=sin(t); y=cos(t); z=sin(2*t); plot(t,x,'--k*',t,y,'-rs',t,z,':bo')

  4. plot 举例

  5. (a < t <b) 三维螺线 例:绘制类似田螺线的一条三维螺线(方程可自己设计) t=0:0.1:30; x=2*(cos(t)+t.*sin(t)); y=2*(sin(t)-t.*cos(t)); z=1.5*t; plot3(x,y,-z); axis equal

  6. 墨西哥帽子 例:用 mesh函数绘制 “墨西哥帽子” x=-8:0.4:8; y=-8:0.5:8; [X,Y]=meshgrid(x,y); r=sqrt(X.^2+Y.^2)+eps; Z=sin(r)./r; mesh(X,Y,Z) axis square

  7. 马鞍面 例:用 surf函数绘制马鞍面 x=-25:25; y=-25:25; [X,Y]=meshgrid(x,y); Z=X.^2/9-Y.^2/4; surf(X,Y,Z); title('马鞍面') grid off

  8. 圆环面 例:用 ezmesh和 ezsurf分别绘制一个圆环面, 并将它们放在一个图形界面内,观察它们的不同之处

  9. 圆环面 • 圆环面方程 • 参数方程:

  10. 圆环面 • 以 R=6, r=2为例 subplot(1,2,1); ezmesh('(6+2*cos(u))*cos(v)', ... '(6+2*cos(u))*sin(v)', '2*sin(u)', ... [0,2*pi,0,2*pi]); axis equal; title('ezmesh'); subplot(1,2,2); ezsurf('(6+2*cos(u))*cos(v)', ... '(6+2*cos(u))*sin(v)', '2*sin(u)', ... [0,2*pi,0,2*pi]); axis equal; title('ezsurf');

  11. 黎曼函数图形 例:绘制黎曼函数图形 为既约分数 为无理数,或 0, 1 源代码见附录 B

  12. find(条件) • 找出符合条件的元素所在的位置 例: a=[4,5,78,121,3,65,24,2]; b=find(a>10) find 命令 • 关于find命令 find(A) • 找出矩阵 A 中非零元素所在的位置(下标) 例: x=[0,4,0,-1,0,0]; y=find(x) A=[0,4,0; -1,0,0]; [y1,y2]=find(A) y=find(A)

  13. find(条件) • 比较: 例: a=[4,5,78,121,3,65,24,2]; b=find(a>100) subplot(1,2,1); plot(a) a(b)=nan; subplot(1,2,2); plot(a) find 命令应用之一

  14. find 命令应用之二 • 先设 r=2;step=1; clear;clc;home r=2;step=1; [X,Y]=meshgrid(-r:step:r); Z=ones(size(X)); subplot(1,2,1) mesh(X,Y,Z) % Z(1,1)=nan;Z(5,1)=nan;Z(5,5)=nan;Z(1,5)=nan; Pos=find(sqrt(X.^2+Y.^2)>r); Z(Pos)=nan; subplot(1,2,2) mesh(X,Y,Z)

  15. find 命令应用之二(续) • 再设 r=2;step=0.1; clear;clc;home r=2;step=0.1; [X,Y]=meshgrid(-r:step:r); Z=ones(size(X)); subplot(1,2,1) mesh(X,Y,Z) % Z(1,1)=nan;Z(5,1)=nan;Z(5,5)=nan;Z(1,5)=nan; Pos=find(sqrt(X.^2+Y.^2)>r); Z(Pos)=nan; subplot(1,2,2) mesh(X,Y,Z)

  16. 上机作业 • 上机作业 要求填写实验报告 1、特殊函数绘图:教材第 67 页, 1~6 文件名分别取为 hw11.m, hw12.m, hw13.m, hw14.m , hw15.m, hw16.m • 提示: 1. 用 ezsurf和 hold 2. 用 mesh、meshgrid、subplot、axis、find 4. 写出参数方程 5. 用 meshz、meshgrid、colormap、grid、title 6. 自学 input的用法

More Related