- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Matlab速入门
Matlab在科研中的应用浙江大学控制系2013年11月10日目录IntroductionCurrent Directory BrowserEditor/DebuggerMatrices and Magic SquaresEntering MatricesYou can enter matrices into MATLAB in several different ways:?Enter an explicit list of elements.?Load matrices from external data files.?Generate matrices using built-in functions.?Create matrices with your own functions in M-files.A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1]MATLAB displays the matrix you just entered.A =16 3 2 135 10 11 89 6 7 124 15 14 1sum, transpose, and diagsum(A)MATLAB replies withans =34 343434Aans =16 5 9 43 10 6 152 11 7 1413 8 12 1sum(A)produces a column vector containing the row sumsans iag(A) %找对角线上的元素ans =161071sum(diag(A))ans =34fliplr(A) %左右翻转sum(diag(fliplr(A)))ans =34A(1,4) + A(2,4) + A(3,4) + A(4,4)This producesans =34The Colon Operator %冒号操作符1:101 2 3 4 5 6 7 8 9 10To obtain nonunit spacing, specify an increment. For example,100:-7:50is100 93 86 79 72 65 58 51and0:pi/4:piis0 0.7854 1.5708 2.3562 3.1416A(1:k,j)is the first k elements of the jth column of A.sum(A(1:4,4))computes the sum of the fourth column.sum(A(:,end))sum(1:16)/4which, of course, isans =34The magic FunctionB = magic(4)B =16 2 3 135 11 10 89 7 6 124 14 15 1A = B(:,[1 3 2 4]) %每一行与B相应的列对应A =16 3 2 135 10 11 89 6 7 124 15 14 1ExpressionsLike most other programming languages, MATLAB provides mathematicalexpressions, but unlike most programming languages, these expressionsinvolve entire matrices. The building blocks of expressions are:?Variables?Numbers?Operators?FunctionsOperatorsExpressions use familiar arithmetic operators and precedence rules.+ Addition- Subtraction* Multiplication/ Division\ Left division (described in “Matrices and LinearAlgebra” in Using MATLAB)^ Power Complex conjugate transpose( ) Specify evaluation orderSeveral special functions provide values of useful constants.pi3iImaginary unit, ?-1jSame as iepsFloating-point relative precision, 2-52realminSmallest floating-point number, 2-1022realmaxL
文档评论(0)