MATLAB最早的發(fā)展理念是提供一套非常完善的矩陣運算指ppt課件_第1頁
MATLAB最早的發(fā)展理念是提供一套非常完善的矩陣運算指ppt課件_第2頁
MATLAB最早的發(fā)展理念是提供一套非常完善的矩陣運算指ppt課件_第3頁
MATLAB最早的發(fā)展理念是提供一套非常完善的矩陣運算指ppt課件_第4頁
MATLAB最早的發(fā)展理念是提供一套非常完善的矩陣運算指ppt課件_第5頁
已閱讀5頁,還剩19頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

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最早的發(fā)展理念是提供一套非常完善的矩陣運算指令,但隨著數(shù)值運算需求的演變,matlab已成為系統(tǒng)模擬,數(shù)位訊號處理,科學目視的標準語言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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論