Professional Documents
Culture Documents
Getting Familiar
MATLAB Training
Workshop-2016 at
Karachi Institute of
Power Engineering
Fahad Wallam
Presentation Outline
Introduction to MATLAB
MATLAB Environment
Matrix IOs
Variables, Numbers and Operators
Matrix Operations
Plotting with MATLAB
MATLAB Structures
Hands-on Activity
Signal processing
Image processing
Communications
Control design, test and measurement
Financial modeling and analysis
Computational biology
Many others
High-level language
for technical computing
Development environment
for managing code, files, and data
Interactive tools
for iterative exploration, design, and problem solving
Mathematical functions
for linear algebra, statistics, Fourier analysis, and
optimization, etc.
Graphics functions
for visualizing data in 2-D and 3-D
MATLAB API
for integrating external applications and languages
such as C, Fortran, MS Excel etc. with MATLAB
GUI tools
for building customize graphical user interfaces
Series of
MATLAB MATLAB
commands
Command
M-files Mat-files
line
Viewing a matrix
Full view
Entering the name displays the complete matrix – A
Selected portion view
From i th to j th column of p th to q th rows of a matrix, a colon
“:” is used – A(p:q,i:j)
* Where A is the matrix name
Matrix
» A = [1, 2; 3 4];
A =
1 2
3 4
» B = [ 1 3 5 7;
2,4,6,8
9 8,7 6; 5, 4, 3, 2]
Vector
» x = [1 2 3 4] xB ==
11 23 35 47
Transpose y = 2 4 6 8
» y = x’ 19 8 7 6
25 4 3 2
3
4
MATLAB Workshop – KINPOE 11.07.2019 Fahad Wallam 12
Extracting Sub Matrix
Variables
Variable names are case sensitive; must start with a
letter
Default length of variable name is 63; can be changed
Type, declarations or dimension are not required
Numbers
Conventional decimal notation with optional decimal
point, and leading plus or minus sign
Scientific notation uses the letter e to specify a
power-of-ten scale factor
Imaginary numbers use either i or j as a suffix
MATLAB Workshop – KINPOE 11.07.2019 Fahad Wallam 14
Some Special Variables
3 , -99
0.0001 , 9.6397238
6.02252e23 , 1.60210e-20
1i , -3.141 + 59j
3e5i
+ Addition
- Subtraction
* Multiplication
/ Division A/B AB-1
\ Left division A\B A-1B
^ Power A^B AB
’ Complex conjugate transpose
( ) Specify evaluation order
= Assignment operator NOTE: 56/8 = 8\56
MATLAB Workshop – KINPOE 11.07.2019 Fahad Wallam 17
Relational and Logical Operator
Relational operators
Less than <
Less than or equal <=
Greater than >
Greater than or equal >=
Equal to ==
Not equal to ~=
Logical operators
not ~ highest precedence
and & equal precedence with or
or | equal precedence with and
MATLAB Workshop – KINPOE 11.07.2019 Fahad Wallam 18
Element-Wise Operation
Addition Subtraction
Add scalar number to Subtract scalar number
each element of the from each element of the
matrix matrix
» a=3; » a=3;
» b=[1, 2, 3;4, 5, 6]; » b=[1, 2, 3;4, 5, 6];
» c= b+a » c= b-a
c= c=
4 5 6 -2 -1 0
7 8 9 1 2 3
Multiplication Division
Multiply each element of Multiply each element of
matrix by the scalar matrix by the scalar
number number
» a=3; » a=3;
» b=[1, 2, 3;4, 5, 6]; » b=[1, 2, 3;4, 5, 6];
» c= a*b » c= b/a
c= c=
3 6 9 0.3333 0.6667 1.0000
12 15 18 1.3333 1.6667 2.0000