Matlab复习.ppt_第1页
Matlab复习.ppt_第2页
Matlab复习.ppt_第3页
Matlab复习.ppt_第4页
Matlab复习.ppt_第5页
已阅读5页,还剩47页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

MATLAB 矩阵 变量符号及数值运算M文件编程绘图Simulink BasicMATLAB commandwindow optionalwindows workspacecurrentdirectory typecommandshere Matlab shelpfeatures type help atthecommandpromptandMatlabreturnsalistofhelptopics Matlab shelpfeatures helpfor howtouseMatlab s for statement Matlab shelpfeatures youcanalsoaccess on line helpbyclickingthequestionmarkinthetoolbar separatewindow MATLABVariables 所有的变量都存储在32位浮点格式 nodistinctionbetweenrealandinteger a 3 a 3 0 sameassignmentfor a Matlabiscasesensitive A 3 a 2 A a MATLABVariables 变量名可以使用数字和下划线 case34 6 45 名称必须以字母开头 case 34 6 45 OK 34case 23 45 resultsinasyntaxerror 字符串 文本 变量用单引号 存储为字符数组 title Thisisthetitle MATLABVariables toclearavariablefrommemory a 4 cleara clearallclcclf MATLABVariables 向量生成 columnvectors rowvectors a 1 2 3 aa 123 a 1 2 3 aa 123 usesemi colontoseparaterows usecommatoseparatecolumns MATLABVariables 矩阵生成 2 dimensionalmatrices a 1 2 3 4 5 6 aa 123456 用函数命令生成 ones zeros MATLABVariables 数组的标识和寻访 a 1 2 3 a 2 ans 2 couldalsoreferencebya 1 2 note a 2 1 wouldproduceanerrorbecause a onlyhasonerow MATLABVariables IndexingMatrixelements a 1 2 3 4 5 6 moreexamples a 2 3 ans 6 a 2 2 9 aa 123496 addressing assigning MATLABVariables 创建复数 Typically thevariable i or j isusedtorepresentthecomplexvariable e g Then acomplexnumberisrepresentedas z a ib Re z a Im z b z 23 i 56 zz 23 00 56 00i z 23 j 56 zz 23 00 56 00i MATLABVariables complex valuednumbers Whathappensinthiscase i 3 z 23 i 56 zz Whathappensinthiscase a sqrt 1 z 23 a 56 zz MATLABVariables complex valuednumbers Note areal valuednumberisaspecialcaseofacomplex valuednumber assigninganyelementofamatrixascomplex valuedmakestheentirematrixcomplex valued a 1 2 aa 12 a 1 1 i 5 aa 1 00 5 00i2 00 0 00i MATLABVariables n维数组Structures的创建和调用cellarrays的创建和调用 MATLABOperations Basicoperations addition subtraction multiplication divisionrightdivision leftdivision a 3 b 4 c1 a b c2 a b c1 0 75 c2 1 3333 MATLABOperations Other Scalar Operations Mathrepresentation Matlabinterpretation z y x y exp x y log x y log10 x y sin x y cos x y tan x y asin x y acos x y atan x MATLABOperations Examples y x 0 5 y x 1 2 y sqrt x MATLABOperations Matrices 矩阵的运算法则 Noerror Error D A B D A B D A C D C A D A C D A B D B A Matrixmultiplicationnotcommutative MATLABOperations Left andRight Matrix division Mathrepresentation Matlabinterpretation C A B C B A Remember Amustbesquareandfullrank linearlyindependentrows columns MATLABOperations Matrix变换 Mathrepresentation Matlabinterpretation C A Forcomplex valuedmatrices complexconjugatetranspose B A b a MATLABm files Twotypesofm files区别和联系 脚本文件collectionofcommandsthatMatlabexecuteswhenthescriptis run 函数文件collectionofcommandswhichtogetherrepresentafunction aprocedureoramethod Bothtypesareseparatefileswitha m extension MATLABm files Tocreateanm file opentheMatlabtexteditor Clickonthe page icon TheMatlabtexteditorwindowwillopen MATLABm files ScriptFiles Onthecommandline x 3 0 y x 2 yy 9 0 Inthescriptfilenamedtest m Onthecommandline testy 9 0 MATLABm files ScriptFiles 脚本文件 工作空间内存 x 5 0 test yy 25 0 test mscript MATLABm files ScriptFiles 脚本文件可以调用其它脚本文件 outtery 36 0 inner mscript outter mscript MATLABm files FunctionFiles 函数文件的标准格式 函数的文件名必须是相同的名称作为函数 Thefunctionfilex2 m MATLABm files FunctionFiles r 3 d x2 r dd 9 0 h x2 4 2 hh 17 64 MATLABm files FunctionFiles MultipleInputsandOutputs outputsinsquarebrackets inputsinparentheses 在函数中创建的变量不保留在工作区中 除了输出变量 thefunctiondoesnothaveaccesstoworkspacevariables exceptfortheinputs MATLABm files FunctionFiles variablespassedtothefunctionare copies oftheworkspacevariables Changingtheirvalueinsidethefunctionhasnoeffectontheirvalueintheworkspace MATLAB控制流 while if ifexpressionstatementsend ifexpressionstatements1elsestatements2end Matlabevaluatesexpressionaslogical true or false false equivalenttozero true equivalenttoanynon zeronumber statements anyvalidMatlabcommand whileexpressionstatementsend MATLABFlowControl evaluatingexpression a 4 b 5 c 5 ifa bifb c True False ifsin 0 ifsin pi sin pi 1 22e 16 False True 关系操作 equaltogreaterthan greaterthanorequalto notequalto 逻辑操作 and or while 3 a a 5 MATLABFlowControl The for statement forindex start increment endstatementsend index start increment andenddonotneedtobeintegervalued incrementisoptional ifincrementisnotspecifiedincrementdefaultsto1 indexcanbeincrementedpositive increment 0 ornegative increment 0 loopstopswhenindex end orindex end MATLABFlowControl example scriptfiletocyclethroughxvalues functionfiletogeneratetheyvalues MATLABPlotting 二维曲线和图形 plot x1 y1 x2 y2 x3 y3 xlabel xaxisname ylabel yaxisname title graphname Additionalfunctions gridongridoffaxis xmin xmax ymin ymax MATLABPlotting exampley sin t the plot functionalone MATLABPlotting exampley sin t scriptfiletogenerateagraphofy sin t functionfiletogenerateagraphofy sin t graphsin MATLABPlotting exampley sin t legend rememberstheorderthegraphswereplotted MATLABPlotting Example 图例 二维曲线三维曲线图形的精细控制多子图特殊图形 SimulinkBasics clicktheSimulinkbutton theSimulinkwindow clickthe new button thesimulinkmodelwindow SimulinkBasics createanewmodeloropenanexistingone SimulinkExample Bestthingtodoistogothroughanexample Responsetoa step command 2ndorder constantcoefficient lineardifferentialequation SimulinkExample Getanequivalentblockdiagramforthesystem useintegratorstogetdy dtandy usemousetodragblocksintothemodelwindowandtoconnectblockswitharrows addgainandsummerblocks SimulinkExample SimulinkExample addthestepinputblock SimulinkExample addtheoutputblock SimulinkExample Now doubleclicktheblockstoopenandsettheblock sparameters setinitialcondition setgainvalue setvariablename setoutputformatto array SimulinkExample Tosetthesimulationparameters selectSimu

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论