Introduction to MATLAB(1/22) Short for MATrix LABoratory > Matlab is both a powerful computational environment and a programming language that easily handles matrix and complex arithmetic Mainly including MATLAB and Simulink CDHAW 同停大学 TONGJI UNIVERSITY
Introduction to MATLAB(1/22) Short for MATrix LABoratory ➢ Matlab is both a powerful computational environment and a programming language that easily handles matrix and complex arithmetic ➢ Mainly including MATLAB and Simulink
Introduction to MATLAB(2/22) 念a形 >Advantages of MATLAB ·Ease of use Platform independence Predefined functions 。Plotting Disadvantages of MATLAB Can be slow 。Expensive @日济大学 TONGJI UNIVERSITY
Introduction to MATLAB(2/22) ➢ Advantages of MATLAB • Ease of use • Platform independence • Predefined functions • Plotting ➢ Disadvantages of MATLAB • Can be slow • Expensive
Introduction to MATLAB(3/22 MATLAB Environment > MATLAB Desktop Command Window Figure Windows Edit/Debug Window Command History Window Workspace Browser and Array Editor Help Browser Current Directory Browser CDHAW 细凡济大学 TONGJI UNIVERSITY
Introduction to MATLAB(3/22) MATLAB Environment ➢ MATLAB Desktop • Command Window • Figure Windows • Edit/Debug Window • Command History Window • Workspace Browser and Array Editor • Help Browser • Current Directory Browser
Introduction to MATLAB(4/22 MATLAB Environment MATLAB Desktop Help Browser ATLA甜 回 Commn wintow 111 Command ☐arop学.asY To view or change Window 闐IPx bap OThanbs.a the current directory 811 Workspace Current Directory Browser Browser .c for i=l te 100 ea) PHAW @同陈大学 -2/01/05400W-% Command History TONGJI UNIVERSITY 5 Window
Introduction to MATLAB(4/22) MATLAB Environment MATLAB Desktop Workspace Browser Command Window Current Directory Browser Command History Window To view or change the current directory Help Browser
Introduction to MATLAB(5/22 MATLAB Environment 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; CDHAW 细月济大学 TONGJI UNIVERSITY
Introduction to MATLAB(5/22) MATLAB Environment ➢ 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;
Introduction to MATLAB(6/22 MATLAB Environment He Edt Debus Deptog wedew Hep 5如年刀灯m与A到匠情约喻 Suppose that you To get started,select MATLAB Help or Demos from the Help menu. want to calculate the Fle r502.m M area=pi*2.52 area of a circle with a 编 3:055.m G:056m area= radius of 2.5 m. 金 G:05t7.m 51m Fle 19.6350 >x1=1+1/2+13+1/4+1/5+1/6g >X1=1+1/2+13-14… and Hist向y +1/5+1/6 128-22上午1164 77 i2.52 /
Introduction to MATLAB(6/22) MATLAB Environment Suppose that you want to calculate the area of a circle with a radius of 2.5 m
Introduction to MATLAB(7/22 MATLAB Environment The Command History Window Command History nargin(Ex0511) 白%一一 12-8-5上午4:16--% nargin('fun',ex0511) nargin (Ex0511) nargin('Ex0511') nargin('ex0511') nargout(ex0511’) 白%一一 12-8-25 Cut Ctrl+X -launch pa Copy Ctrl+C clc Evaluate Selection 白% 12-8-25 reap2水2 Create M-File x1=1+1/2+ Create Shortcut x1=1+1/2+ Profile Code +1/5+1/6: Delete Selection Delete to Selection 同停大学 Clear Entire History TONGJI UNIVERSITY Start
Introduction to MATLAB(7/22) MATLAB Environment The Command History Window
Introduction to MATLAB(8/22 MATLAB Environment The Edit/Debug Window >Create new M-files 。File/New/M-file' .Clicking the DToolbar icon Input edit'in the command window >Open an existing one .File/Open” .Clicking the Toolbar icon @月济大学 AW TONGJI UNIVERSITY
Introduction to MATLAB(8/22) MATLAB Environment ➢Create new M-files •“File/New/M-file” •Clicking the Toolbar icon • Input ‘edit’ in the command window ➢Open an existing one •“File/Open ” •Clicking the Toolbar icon The Edit/Debug Window
Introduction to MATLAB(9/22 MATLAB Environment The Edit/Debug Window MATLAB 回 File Edit Debug Desktop Window Shorteuts [e]How to Add what'e New Current Directory G201 Command winclow 白半网包见· >cale_area 】Ex0511a ASV File The area of the cirele is 19.635 Ex0511.m >> MAT-file calc_area.m M-file Current Directory Workepaoe Command History 12 -Iaunch pad 825上午143—% 66 +1/d+1/5+1/ 1=1+1/2+1/3+1/a +1/5+1/6 calc_area @月海大学 TONGJI UNIVERSITY
Introduction to MATLAB(9/22) MATLAB Environment The Edit/Debug Window
MATLAB Basics(10/22) MATLAB Environment >A program can be input command by command using the command line(lines starting with“y”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 PHAW @日济大学 TONGJI UNIVERSITY
MATLAB Basics(10/22) MATLAB Environment ➢ A program can be input • command by command using the command line (lines starting with “»” 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