Professional Documents
Culture Documents
Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data Types Input/Output Functions Simulink Toolbox Important Toolboxes (if time is available) Dr. Nidal Farhat
Objectives:
Advantages and Disadvantages of Matlab Matlab == MATrix LABoratory Advantages: Ease of Use Platform Independent (All versions of Windows, Linux, Unix, Mac.) Predefined Functions and Toolboxes Device-Independent Plotting Graphical User Interface Matlab compiler
Matlab Command Window User input area Current directory browser Also results appear in this window
Command history
10
whos Display the value of any variable in the WS clear var1 var2 Double-click any var in the WS browser
11
12
13
14
15
16
17
A few important commands clc: clf: clear: clears command window clears current figure clear variables in the WS
exit:
exits Matlab
runs the command in the operating system (ex. dir, copy )
!(command):
18
If a command (name) is executed Matlab seeks for: A variable with the same name in the current WS. M-file in the same directory M-file in the any directory in the search path
Sequence is important
19
56/8 = 8\56
Addition:
Subtraction: Assignment:
(+)
(-) (=)
a+b
ab a=b (assign b to a)
20
HW1 The distance traveled by a ball falling in the air is given by the equation
1 2 y y0 v0t at 2
Use the Matlab to plot the path of the ball (y) as a function of time from t=0s to t=5s, if
21