Prem MATLAB Notes
Prem MATLAB Notes
• Advantages
– Fast implementation and debugging
– Natural matrix operation
– Powerful image processing toolbox
Matlab Main Screen
Command Window
Type and execute
commands
Running programs
composed by user
Current Directory
View folders and m-
files
Workspace
View variables
Double click on a
variable to see it in the
Array Editor
Command History
view past commands
save a whole
Matlab Main Screen
Editor Window
For writing & editing
programs
For creating script
files & function files
Figure window
Show graphs in result
of graphics command
Help Window
Contains information
for any features of
MATLAB
Input –Output in MATLAB
Data Type -
Fundamental data type is an Array
No need to worry about data type or data object declarations
Dimensioning
Automatic in MATLAB
No dimension statements are required
Case sensitivity
MATLAB is case sensitive.
A and a are different variables.
MATLAB commands and built-in function are typed in lower case.
Output Display
Output of every command is displayed on the unless MATLAB is directed
otherwise.
A semicolon at the end of a command suppresses the screen output,
except for graphic and online help commands.
File type in MATLAB
M-files
.m extension
Script files and function files
Mat-files
.mat extension
Binary data files created by MATLAB and only MATLAB can read.
It can be loaded into MATLAB with the load command.
Fig-files
.fig extension
P-files
.p extension
General commands
Outline
1. Introduction
1. Overview
2. Variables
3. Matrix
4. Misc.
2. Image Processing with Matlab
3. References
Variables
Defining variables
int >>a=1;
a; >>b=2+
a=1 4;
;
double
b; Matla
b=2+4; b
Variables are created when they are used
C/C++
b=
false;
Variables
B=
[1,2,3;4,5,6]
1 2 3
4 5 6
7 8 8
Variables
B=C(2:3, 1:3)
Get those elements of C that are
located in rows 2 & 3 and columns 1 to
3
B=
1 2 3
4 5 6
7 8 8
Variables
D=[1 ; 2 ;
3]
E=[1 2 3]’
Variables
Variables
Column-Major
Order
Matrix Index
>> >> >> A(2,:)
A(2,2:3) A(2,1:end)
ans =
ans = ans =
4 5
5 4 5 6
6 >> A(:)
6
ans =
A(1:2,3:end)
http://www.mathworks.com/company/newsletters/articles/matrix-indexing-
in-matlab.html
Matrix Operations
+ addition
- subtraction
* multiplication
^ power
‘ complex conjugate transpose
Matrix Operations
Given A and
B: