




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Introduction to MATLABCheng-Hsiung ChiangDepartment of Computer ScienceHsuan Chuang University1.OutlineThe history of MATLABThe toolboxes of MATLABHow to use MATLAB software?Programming using MATLABBasic commandsWrite a function of MATLABArrays and matrixesOperations of arrays and matrixesMatlab fun
2、ctionsControl proceduresInput and outputPlottingExamples of MATLAB programs2The History of MATLABMATLAB ( Matrix Laboratory) is developed by The MathWorks, Inc., 1984.MATLAB最早的發展理念是提供一套非常完善的矩陣運算指令,但隨著數值運算需求的演變,matlab已成為系統模擬,數位訊號處理,科學目視的標準語言3MATLAB is the leading computational software forProduct des
3、ign and developmentResearch in industry and academiaTechnical education Over 400,000 MATLAB users worldwideUsed in over 100 countries4How powerful the MATLAB can be?“For the purposes of an engineer or scientist, MATLAB has the most features and is the best developed program in its class. -IEEE Spect
4、rum, Software Review, February 1997“I have been amazed at how MATLAB can boost ones productivity. Anything from simple analysis to complex modeling and simulation can be done in a fraction of the time it would take to write your own code.Gregory E. Chamitoff, Ph.D.NASA, Johnson Space Center5The Tool
5、boxes of MATLABCommunications ToolboxControl System ToolboxData Acquisition ToolboxDatabase ToolboxDatafeed ToolboxFilter Design ToolboxFinancial Derivatives ToolboxFinancial Derivatives ToolboxFinancial ToolboxFuzzy Logic ToolboxGARCH ToolboxImage Processing ToolboxInstrument Control ToolboxModel P
6、redictive Control ToolboxMapping ToolboxMu Analysis And Synthesis ToolboxNeural Network ToolboxOptimization ToolboxPartial Differential Equations (PDE) ToolboxRobust Control ToolboxSignal Processing ToolboxSpline ToolboxStatistics Toolbox Symbolic Math ToolboxSystem Identification ToolboxWavelet Too
7、lbox6How to use MATLAB?Install MATLABExecute MATLABThe MATLAB windowsDemos of MATLAB7Programming Using MATLABFile types of MATLAB.m file.fig files.mat filesBasic Commands in command windowsave load help whoclearclcexit/quit8Mathematical OperationsDeclaring a variableA = 5;% the “; is for not display
8、B = 6;MATLAB Math & Assignment OperatorsPoweror.abor a.bMultiplication* or.*a*bora.*bDivision/or./a/bora./b oror.baorb.aNOTE: 56/8 856Addition+ a + bSubtraction- a - b9Write a Function of MATLABHow to edit a function for MATLAB?An example of a MATLAB functionfunction total = sum(n) % This program is
9、 to calculate the summationsum = 0; for i = 1 : 10,sum = sum + I;end;% end of for loopend;% end of functionHow to call a function?10Arrays and MatrixesArray: ex. 1x6 arrayA = 1 2 3 4 5 6;orA = 1, 2, 3, 4, 5, 6;Matrix: ex. 2x3 matrixB = 1 2 3; 4 5 6; 7 8 9; orB = 1 2 3 4 5 6 7 8 9;A(1) = ? A (6) = ?
10、B(1,2) = ? B (1,:) = ? B(:,1) = ?Examples:11Operations of Arrays and MatrixesThe mathematical operations of array and matrix12Matlab FunctionsThe MATLAB functions13Flow control - selectionThe if-elseif-else constructionif elseif else endif height170 disp(tall)elseif height150 disp(small)else disp(av
11、erage)end14Logical expressionsRelational operators (compare arrays of same sizes)= =(equal to)= (not equal) (less than)(greater than)= (greater than or equal to)Logical operators (combinations of relational operators)&(and)|(or)(not)Logical functionsxorisemptyanyallif (x=0) & (x=10) disp(x is in ran
12、ge 0,10)else disp(x is out of range)end15Flow control - repetitionRepeats a code segment a fixed number of timesfor index= endThe are executed repeatedly.At each iteration, the variable index is assigneda new value from .for k=1:12 kfac=prod(1:k); disp(num2str(k), ,num2str(kfac)end16Example selectio
13、n and repetitionfunction y=fact(n)% FACT Display factorials of integers 1.nif nargin 1 error(No input argument assigned)elseif n eps error(Input must be an integer)endfor k=1:n kfac=prod(1:k); disp(num2str(k), ,num2str(kfac) y(k)=kfac;end;17Repetition: Animation demoThe function movie replays a sequ
14、ence of captured framesConstruct a movie of a 360 tour around the Matlab logo% logomovie make movie of 360 degree logo tour logo;no_frames=40;dtheta=360/no_frames;for frame = 1:no_frames, camorbit(dtheta,0) M(frame) = getframe(gcf);end% now display captured moviemovie(gcf,M);18Flow control condition
15、al repetitionwhile-loops are executed repeatedly as long as the evaluates to truewhile endk=1;while prod(1:k)=Inf, k=k+1; enddisp(Largest factorial in Matlab:,num2str(k-1);19Input and OutputX = input(enter your name,s)Y = input(enter your age,a)Disp(X)fprintf(fid,%6.2f n,y)20PlottingPolar plot: t=0:.01:2*pi; polar(t,abs(sin(2*t).*cos(2*t);Line plot:x=0:0.05:5;,y=sin(x.2);,plot(x,y); Stem plot: x = 0:0.1:4;, y = sin(x.2).*exp(-x); stem(x,y)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 煤炭安全管理人员考试试题试题及答案
- 临床医学检验技术(师):临床检验基础
- 2025年专升本艺术概论考试模拟卷(艺术理论前沿热点知识问答与解析)含答案
- 海洋空间资源优化配置
- 老王P课件特点介绍
- 老年人照护职业培训课件
- 2025年八角行业分析报告及未来五至十年行业发展报告
- 餐饮店面租赁及品牌推广合同
- 车抵押贷款纠纷处理合同
- 水利泵站工程信息化建设与运维合同范本
- MH-T 5078.4-2024 运输机场建设工程资料管理规程 第4部分:目视助航设施工程施工资料
- 打击非法行医非法采供血和规范医疗机构执业行为
- 水处理反渗透设备日常维护保养点检记录表
- 档案整理及数字化服务方案
- 《讲师技能培训》课件
- 设备日常点检表
- 土力学与地基基础(课件)
- 青岛版二年级数学下册(六三制)全册课件【完整版】
- (完整版)初中生物实验报告单
- 2023年医技类-超声医学(副高)考试历年真题集锦附答案
- 复合不定代词
评论
0/150
提交评论