1 / 63

Matlab 原来是 Matrix Laboratory( 矩阵实验室)的缩写,主要用来处理矩阵等代数运算,后来发展为通用科技计算、图视交互系统和程序语言。

Matlab 原来是 Matrix Laboratory( 矩阵实验室)的缩写,主要用来处理矩阵等代数运算,后来发展为通用科技计算、图视交互系统和程序语言。. 命令行运行方式 M 文件运行方式. 二、 Matlab 中的窗口. 命令窗口. 提示. 例如: a, A, li_2003, Li2003n …… 都是合法的。. 工作空间窗口. 工作区( workplace): 接受 Matlab 命令的内存区域,存储着命令窗口输入的命令和创建的所有变量值。. 命令 M 文件没有输入参数,也不返回输出参数,只是一些命令行的组合。.

lewis
Download Presentation

Matlab 原来是 Matrix Laboratory( 矩阵实验室)的缩写,主要用来处理矩阵等代数运算,后来发展为通用科技计算、图视交互系统和程序语言。

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. Matlab原来是Matrix Laboratory(矩阵实验室)的缩写,主要用来处理矩阵等代数运算,后来发展为通用科技计算、图视交互系统和程序语言。

  2. 命令行运行方式 • M文件运行方式 二、Matlab中的窗口

  3. 命令窗口

  4. 提示

  5. 例如:a, A, li_2003, Li2003n …… 都是合法的。

  6. 工作空间窗口 工作区(workplace):接受Matlab命令的内存区域,存储着命令窗口输入的命令和创建的所有变量值。

  7. 命令M文件没有输入参数,也不返回输出参数,只是一些命令行的组合。

  8. 2、帮助窗口 3、演示帮助

  9. 分号为了不显示中间过程 该分号为了换行 • B=[0,1,-4;-2,3,1]; • A+B • A-B 注意: 同型矩阵才能进行加减运算.

  10. 注意: 只有满足矩阵相乘条件才能进行乘法及方幂运算. • 例2: A=[1,2,3;2,3,4;0,-2,-1]; • B=[-1,2;0,1;-2,3]; • C=[4,5,6;-4,5,3;-9,0,-2]; • A*B • A .*B • A^3 • A .^ 3 同型两矩阵才能点数乘,它们是对应元素相乘 数组的点方幂的对应元素的方幂

  11. 例3:求解方程组: 解:A=[2,1,-5,1;1,-3,0,-6;0,2,-1,2;1,4,-7,6] b=[8,9,-5,0] ’ x=A\b ………………%求解AX=b型方程组. 求矩阵的转置

  12. 例4:A=[1,2;2,1] B=[2,1;1,2] A./B B.\A 关系为A.\B=B./A

  13. 7.由函数生成矩阵

  14. 7.由函数生成矩阵

  15. 7.由函数生成矩阵

  16. flipud(A) 矩阵作上下翻转

  17. 0 例1. 正弦函数图形 x = 0:10; y = sin(x); xi = 0:.25:10; yi =sin(xi); plot(x,y,'o',xi,yi)

  18. 例2 衰减振荡函数: y=e -0.5xsin 5x图形. 命令: x=0:0.1:4*pi; y= exp(-0.5*x).*sin(5*x); plot(x,y)

  19. (2) plot(x1,y1,x2,y2); 例3. 在同一坐标系下作出两条曲线y=sin(x)和y=cos(x) 在[0,2π]上的图形 . 方法(二) x=linspace(0,2*pi,30); y1=sin(x);y2=cos(x); plot(x,y1,x,y2) 方法(一): x=linspace(0,2*pi,30); y=[sin(x),cos(x)]; plot(x,y)

  20. 例4.绘制极坐标图形: 调用格式:polar(theta,rho); x=linspace(0,2*pi,1000); y=sin(2*t).*cos(2*x); polar(x,y)

  21. 颜色:y黄; r红; g绿; b蓝; w白; k黑; m紫; c青 线型: -(实线); :(点线); -.(虚点线); - -(虚线) 数据点图标: .(小黑点); +(加号); *(星号); o(小圆圈) pentagram(五角星)

  22. 同一坐标系 不同坐标系

  23. 例5:用subplot分别在不同的坐标系下作出 下列四条曲线,为每幅图形加上标题. (1) y=sinx; (2) y=cosx; (3) y=2sinx*cosx (4) y=2sinx/cosx

  24. 命令: x=linspace(0,2*pi,30);y=sin(x);z=cos(x); u=2*sin(x).*cos(x);v=2*sin(x)./cos(x); subplot(2,2,1),plot(x,y),title(‘sinx’) subplot(2,2,2),plot(x,z),title(‘cosx’) subplot(2,2,3),plot(x,u),title(‘2sinx*cosx’) subplot(2,2,4),plot(x,v),title(‘sinx/cosx’)

  25. 例6、作螺旋线x=sint,y=cost,z=t 命令: t=linspace(0,10*pi,100) plot3(sin(t),cos(t),t)

  26. 例2 (巴拿马草帽图形) 命令: x=-8:0.5:8; y=x; [X,Y]=meshgrid(x,y); r=sqrt(X.^2+Y.^2)+eps; Z=sin(r)./r ; mesh(X,Y,Z) 没有它,会出现什么?

  27. 命令: x=-8:0.5:8;y=x;[X,Y]=meshgrid(x,y); R=sqrt(X.^2+Y.^2)+eps; Z=sin(R)./R; subplot(2,2,1),mesh(X,Y,Z) subplot(2,2,2),meshc(X,Y,Z) subplot(2,2,3),surf(X,Y,Z) subplot(2,2,4),surfl(X,Y,Z)

  28. For语句 While语句 if—end语句 switch—case语句 顺序结构 程 序 结 构 循环结构 分支结构

More Related