1、70%TestsAn in-class open-book final,1 Introduction(1.1-1.5)2 MATLAB Basics(2.1-2.10,2.13,2.14)3 Top-down Program Design(3.1-3.2)4 Relational and Logical Operators(3.3,4.3)5 Branches and Loops(3.4,4.1,4.2,4.4)6 Plotting(2.11,3.5,6.4,6.5)7 User-defined Functions(5.1-5.9)8 Complex Data and Character Da
2、ta(6.1-6.3)9 Input/Output Functions(8.1-8.11)10 Sparse Arrays,Cell Arrays,and Structures(7.1-7.5),Contents,Introduction to MATLAB,MATrix LABoratory,MATLAB arrayAdvantages of MATLABEase of usePlatform independencePredefined functionsPlottingDisadvantages of MATLABCan be slowan interpreted languageExp
3、ensive,MATLAB Environment,MATLAB DesktopCommand WindowFigure WindowsEdit/Debug WindowCommand History WindowLaunch PadWorkspace Browser and Array EditorHelp BrowserCurrent Directory Browser,MATLAB Desktop,Workspace Browser,Command Window,Current Directory Browser,Command History Window,To view or cha
4、nge the current directory,Help Browser,MATLAB Desktop,Launch Pad,The Command Window,The command prompt()is predefined,use pi Ellipsis(),continuing on the next line x1=1+1/2+1/3+1/4+1/5+1/6;and x1=1+1/2+1/3+1/4+1/5+1/6;,The Command History Window,The Launch Pad,The Edit/Debug Window,Create new M-file
5、s“File/New/M-file”Clicking the Toolbar icon Open an existing one“File/Open”Clicking the Toolbar icon,The Edit/Debug Window,Figure Windows,The MATLAB Workspace,whosvar1clear Deletes all variablesclear var1 var2,The Workspace Browser,Getting Help,Use the Help BrowserSelecting the Help iconTyping helpd
6、esk or helpwin in the Command window,Getting Help,Command_line oriented way to get helpType help or help fun1 in the command windowSearches for an exact function name matchType lookfor commandSearches the quick summary information in each function for a match,A Few Important Commands,Type demo or se
7、lect“demos”in the Launch Padclc clfClearc(control-c),abort!Invoke operating system commanddiary(diary fileneme,diary off,diary on),The MATLAB Search Path,Enter a name at the MATLAB promptLook for the name as a variableCheck to see if it is a built-in function or commandCheck to see if it is an M-fil
8、e in the current directoryCheck to see if it is an M-file in any directory in the search path,The MATLAB Search Path,Programming PitfallsNever use a variable with the same name as a MATLAB function or commandNever create an M-file with the same name as a MATLAB function or commandExamine and modify
9、search path“File/Set Path”,editpath,pathtoolpath command,Using MATLAB as a Scratchpad,+,-,*,/,For example r=0.1;l=0.5;V=A*l;A=pi*r2;V=A*l V=0.0157,2022/10/14,Mathematical Modeling,24,MATLAB常用数学函数(1),三角函数和双曲函数,2022/10/14,Mathematical Modeling,25,MATLAB常用数学函数(2),指数函数,取整函数和求余函数,2022/10/14,Mathematical
10、Modeling,26,MATLAB常用数学函数(3),矩阵变换函数,复数函数,2022/10/14,Mathematical Modeling,27,MATLAB常用数学函数(4),矩阵函数,2022/10/14,Mathematical Modeling,28,MATLAB常用数学函数(5),其他函数,Homework,Quiz 1.1 Exercises1.1,1.4,MATLAB Basics,MATLAB Basics,A program can be inputcommand by command using the command line(lines starting with
11、“”on the MATLAB desktop)as a series of commands using a file(a special file called M-file)If a command is followed by a semicolon(;),result of the computation is not shown on the command window,MATLAB Basics:Variables,Variable is a name given to a reserved location in memoryclass_code=111;number_of_
12、students=65;name=Sichuan Normal University;radius=5;area=pi*radius2;,MATLAB Basics:Variables,Use meaningful names for variablesMATLAB variable namesmust begin with a lettercan contain any combination of letters,numbers and underscore(_)must be unique in the first 31 charactersMATLAB is case sensitiv
13、e:“name”,“Name”and“NAME”are considered different variablesNever use a variable with the same name as a MATLAB commandNaming convention:use lowercase letters,MATLAB Basics:Arrays,The fundamental unit of data is array scalar value vector matrix,MATLAB Basics:Initializing Variables,Initialization using
14、 assignment statementsx=5x=5y=x+1y=6vector=1 2 3 4 vector=1 2 3 4,matrix=1 2 3;4 5 6 matrix=1 2 3 4 5 6matrix=1 2 3;4 5?Errora=5(2+4)a=5 6,MATLAB Basics:Initializing Variables,Initialization using shortcut statementscolon operator first:increment:lastx=1:2:10 x=1 3 5 7 9y=0:0.1:0.5y=0 0.1 0.2 0.3 0.
15、4 0.5,MATLAB Basics:Initializing Variables,transpose operator u=1:3 u=1 2 3v=u u v=1 1 2 2 3 3,v=u;u v=1 2 3 1 2 3,MATLAB Basics:Initializing Variables,Initialization using built-in functionszeros()x=zeros(2)x=0 0 0 0z=zeros(2,3)z=0 0 0 0 0 0ones(),size(),length(),y=zeros(1,4)y=0 0 0 0t=zeros(size(z
16、)t=0 0 0 0 0 0,MATLAB Basics:Initializing Variables,Initialization using keyboard inputinput()value=input(Enter an input value:)Enter an input value:1.25value=1.2500name=input(What is your name:,s)What is your name:Selimname=Selim,MATLAB Basics:Initializing Variables,Initializationc(:,:,1)=1 2 3;4 5 6;c(:,2)=7 8 9;10 11 1
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1