1 / 17

MATLAB 介绍

MATLAB 介绍. MATLAB 中一些 简单命令介绍 与学习 MATLAB 中 M-- 文件的简单介绍与学习 MATLAB 中二维、三维图形的介绍与学习 MATLAB 中简单动画的制作与学习 谢谢大家 !. MATLAB 命令 简单介绍.

ardara
Télécharger la présentation

MATLAB 介绍

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介绍 • MATLAB中一些简单命令介绍与学习 • MATLAB中M--文件的简单介绍与学习 • MATLAB中二维、三维图形的介绍与学习 • MATLAB中简单动画的制作与学习 • 谢谢大家!

  2. MATLAB命令简单介绍 • MATLAB是建立在向量、数组和矩阵基础上的一种分析和仿真工具软件包,包含各种能够进行常规运算的“工具箱”,如常用的矩阵代数运算、数组运算、方程求根、优化计算及函数求导积分符号运算等;同时还提供了编程计算的编程特性,通过编程可以解决一些复杂的工程问题;也可绘制二维、三维图形,输出结果可视化。目前,已成为工程领域中较常用的软件工具包之一。

  3. 运行MATLAB会创建一个或多个窗口 a)命令区(Command Window)是用户使用的主要场所,此时,可以输入变量、数组及运算命令,进行一些简单的运算;用↑↓←→键搜索、修改以前使用过的命令操作, 用clc清除窗口; 用help sqrt ( help input …)寻求有关帮助; b)编辑区(Editor\Debugger Window)编制各种M-文件,存盘(Save)、运行(Run)等.

  4. MATLAB中与数学相关的常用的工具箱 在命令区(Command Window)键入help命令,可查看工具箱; matlab\elmat - Elementary matrices and matrix manipulation. matlab\elfun - Elementary math functions. matlab\specfun - Specialized math functions. matlab\matfun - Matrix functions - numerical linear algebra. matlab\datafun - Data analysis and Fourier transforms. matlab\polyfun - Interpolation and polynomials. matlab\funfun - Function functions and ODE solvers. matlab\graph2d - Two dimensional graphs. matlab\graph3d - Three dimensional graphs. matlab\specgraph - Specialized graphs.

  5. MATLAB中与数学相关的常用的工具箱 nnet\nnet - Neural Network Toolbox. nnet\nndemos - Neural Network Demonstrations. toolbox\optim - Optimization Toolbox. toolbox\pde - Partial Differential Equation Toolbox. toolbox\splines - Spline Toolbox. toolbox\stats - Statistics Toolbox. toolbox\symbolic - Symbolic Math Toolbox. wavelet\wavelet - Wavelet Toolbox.

  6. 工具箱及命令查询 help topics 在命令区(Command Window)键入 help ops help lang help elfun help fabs help sqrt

  7. MATLAB中基本代数运算符 运算 符号 举例 加法,a+b + 5+3 减法,a-b - 5-3 乘法,a×b * 5*3 除法,a÷b / or \ 48/4=4\48=12 乘幂,ab ^ 5^2=25

  8. MATLAB中数组、矩阵基本运算符 运算 符号 举例 加法,a+b + [1 2]+[3 4] [1,2]+3 减法,a-b - [1 2]-[3 4] [1,2]-3 乘法,a*b * [1,2]*3 [1,2]‘*[3,4] a.*b .* [1,2].*[3,4]=[3,8] 逆乘,左乘 \ ax=b  x=a\b=inv(a)*b 右乘 / xa=b  x=b’/a=b’*inv(a) 乘幂,方阵的幂 ^ a^2=a*a 元素的幂 .^ a.^2 x.^3

  9. 变量及数组输入 • MATLAB的变量及数组均是以向量或矩阵方式存储的 • 1:向量方式输入 x=[1,2,3,4,5] %以向量(数组)方式给x赋值 y=(x(3)+x(5))/2*x(4) %调用x中的元素 z=sqrt(x) %每个元素开方 t=x' %向量x的转置赋给t u=x*t %向量的内积(u为向量x的模的平方)

  10. 变量及数组输入 • 2:矩阵方式输入 a=[1,2,3;4,5,6;7,8,0] %矩阵输入 (a为3阶方阵) b=[366;804;351] %列矩阵输入 det(a) %方阵行列式 inv(a) %方阵的逆 x=a\b %ax=b方程组的解 y=inv(a)*b %与x相同 disp([a,b,x]) %显示矩阵

  11. 变量及数组输入 • 3:矩阵的简单运算 c=inv(a) %方阵的逆阵 y=c*b %矩阵乘积 d=[a b];disp([d]) %矩阵拼接 d=a'; disp([d]) %矩阵转置 g=2*a+3 %常数乘矩阵,各元素加3 p=eye(3) %3阶单位矩阵 y=a.*p %两矩阵对应元素乘积 zeros(3) %3阶零矩阵

  12. 变量及数组输入 • 4:数组的分点输入和步长输入 x=linspace(0,2*pi,30); %按分点赋值 y=50*sin(x); plot(x,y);%画正弦曲线 plot(x,y, 'r*'); hold on t=0:0.5:7 z=t.^2; plot(t,z, 'bo');%画y=x^2曲线 plot(t,z, 'r--');

  13. MATLAB中关系和逻辑运算 • 关系运算符 逻辑运算符 > >= < <= == ~= &(and) | (or) ~(not) • x=linspace(0,10,100); y=sin(x); z=(y>=0).*y; (z=(y>0 | y==0).*y; z=z+.5*(y<0); plot(x,z)

  14. MATLAB中符号函数的表示 符号函数 MATLAB表示 '1/(2*x^n)' '1/sqrt(2*x)' 'sin(x^2)-cos(2*x)' M=sym('[a,b;c,d]') f=int('x^2/sqrt(1-x)', 'a', 'b')

  15. MATLAB中符号运算 • fx='2*x^n' %建立函数 diff(fx) %对变量x求一阶导数 diff(fx, 'n',2) %对变量n求二阶导数 • fx='x/(1+x^2)' int(fx) %对fx求不定积分 int(fx,0, 't') %对fx在[0,t]上求定积 • syms x fy=1/(1+x^2) taylor(fy) %对fy在x=0点求泰勒展开式(6项) taylor(fy,8,1) %对fy在x=1点求泰勒展开式(8项)

  16. MATLAB中符号运算 • fx='a*x^2+b*x+c' solve(fx) %求方程fx=0的符号解 solve(fx, 'b' ) %求方程fx=0关于变量b的符号解 • fx= '1/(1+exp(-1/x))' limit(fx,x,0, 'right') %求fx:x->0右极限 limit(fx,x,0, 'left') %求fx:x->0左极限 limit(fx,x,inf) %求fx:x->∞极限

More Related