MATLAB Tutorial by Ashish Jangid
MATLAB Tutorial by Ashish Jangid
MATLAB
What Is MATLAB?
Why MATLAB
MATLAB Components
Handle Graphics
the MATLAB graphics system. It includes high-level commands for twodimensional and three-dimensional data visualization, image processing,
animation, and presentation graphics.
(contd)
MATLAB Components
MATLAB
Remember:
EVERYTHING IN MATLAB
IS A MATRIX !
creates 1 x 200 Matrix
Matrices
Matrices
Matrices
A = [2 7 4]
2 7 4
A = [2; 7; 4]
2
7
4
A = [2 7 4; 3 8 9]
2 7 4
3 8 9
B = [ AA ]
Matrices
A = [2 7 4]
2 7 4
A = [2; 7; 4]
2
7
4
A = [2 7 4; 3 8 9]
2 7 4
3 8 9
B = [ AA ]
2 7 4 2 7 4
3 8 9 3 8 9
Matrices
Matrices
B=A*A
prints
9 12
24 33
B = A .* A prints
1 4
16 25
Submatrices
b = [3 5 6]
Submatrices
loops
b=0
for i = [ 3 9 17]
b = b + i;
end
Result:
29
Note:
The MATLAB way to write that program would have been:
b = sum([ 3 9 17]);
Avoid loops if possible !
loops
end
Which is the same as:
for i = [1 2 3 4 5 6]
end
loops
Once again:
AVOID LOOPS
Images
Images
Images
Loading an image:
a = imread(picture.jpg);
imshow(a);
Images
R G B
384
512
Images
Color image:
3D Matrix of RGB planes
Images
Images
Images
Plotting
3D Plotting
Simulink
Simulink
Used to model, analyze and simulate dynamic
systems using block diagrams.
Provides a graphical user interface for constructing
block diagram of a system therefore is easy to use.
However modeling a system is not necessarily easy !
Simulink
Simulink
10
100 uF
+
v(t) = 5 sin t
0.01 H
Simulink
10
100 uF
v(t) = 5 sin t
0.01 H
di 1
v iR L
idt
dt C
Simulink
1 dv di R d i
i
2
L dt dt L dt LC
Taking Laplace transform:
sV R
I
2
sI s I
L L
LC
sV 2 R
1
I s s
L
L
LC
Simulink
s(1/ L)
I V
R
1
2
s s
L
LC
s(1/ L)
R
1
2
s s
L
LC
Simulink
It is where we obtain
the blocks to construct
our model
It is here where we
construct our model.
Simulink
simout
s+1
Sine Wave
Transfer Fcn
To Workspace
Simulink
s(1/ L)
R
1
2
s s
L
LC
s(100)
2
6
s 1000 s 1 10
100s
s2+1000s+1e6
Sine Wave
Transfer Fcn
v
To Workspace1
i
To Workspace
Simulink
1
0.5
0
-0.5
-1
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
-5
By the way
Conclusion
In my opinion
In my opinion
Conclusion
CONCLUSION:
Give it a try !
Any
Query
Thank you