Matlab Part 1
Matlab Part 1
Matlab Description
• Where is Matlab
• What is Matlab
• Matlab Desktop
• MATLAB Math Operators
Matrix and Array
• Creation, Operation, Concatenation
Workspace Variables
Calling Functions
2
Where is Matlab?
• MATLAB
– MATrix LABoratory: MATLAB is a program for doing
numerical computation. It was originally designed for solving
linear algebra type problems using matrices. It’s name is derived
from MATrix LABoratory.
– MATLAB has since been expanded and now has built-in
functions for solving problems requiring data analysis, signal
processing, optimization, and several other types of scientific
computations. It also contains functions for 2-D and 3-D graphics
and animation.
4
MATLAB Description
– Student edition
• Available for roughly 1 hundred dollars.
• Some limitations, such as the allowable size of a matrix
http://www.mathworks.com/products/matlab/
5
Matlab Desktop (Cont.)
Launch Pad
Workspace
Current
Directory
Command
History
Window
6
Matlab Desktop (cont.)
• Current Folder
– Access your files
• Command Window
– Enter commands at the command line, indicated by the prompt
(>>).
• Workspace
– view program variables
– double click on a variable to see it in the Array Editor
– Explore data that you create or import from files
• Command History
– View or rerun commands that you entered at the command line
• Launch Pad
– access help, tools, demos and documentation 7
Command window
»a=5;
»b=a/2
b=
2.5000
»
8
MATLAB Math Operators
9
Ex1
11
Outline
Matlab Description
• Where is Matlab
• What is Matlab
• Matlab Desktop
• MATLAB Math Operators
Matrix and Array
• Creation, Operation, Concatenation
Workspace Variables
Calling Functions
12
Matrices and Arrays
13
Creation : Array / Matrix
14
Creation: Matrix (function)
15
Matrix Operations
16
Matrix Operations
19
Matrix Operations
20
Concatenation
A=
1 2 3 1 2 3
4 5 6 4 5 6
7 8 10 7 8 10
21
Concatenation
Matlab Description
• Where is Matlab
• What is Matlab
• Matlab Desktop
• MATLAB Math Operators
Matrix and Array
• Creation, Operation, Concatenation
Workspace Variables
Calling Functions
23
Workspace Variables
24
Workspace Variables
a = [1 2 3; 4 5 6; 7 8 10];
z = zeros(5,1);
A = magic(4);
B = rand(3,5,2);
whos
save lab1.mat
load lab1.mat
26
Outline
Matlab Description
• Where is Matlab
• What is Matlab
• Matlab Desktop
• MATLAB Math Operators
Matrix and Array
• Creation, Operation, Concatenation
Workspace Variables
Calling Functions
27
Calling Functions
29
Calling Functions
30
Help and Documentation
32
More Exercises
2 5 3
• How to assign 7 3 5 to a variable named a ? And
9 1 2
what’s the transpose of a ?
2 5 3 2 7 3
7 3 5 7 10 5
• What’s the summation of and ?
9 1 2 4 1 15
33
What We have Learned?
34
35