Digital Image Processing in Matlab
Digital Image Processing in Matlab
PROCESSING IN
MATLAB
LECTURE 4
3D Line Plots
Plot(1, 1, ‘ro’)
Plot3(1, 1, 1, ‘ro’)
Exercise
Plot these in 3D
Plot3(x, y, z)
15
10
0
1
0.5 1
0 0.5
0
-0.5 -0.5
-1 -1
How to remove specific rows from your matrix?
A=[ 1 2 4;
5 6 7;
8 9 0;
2 6 9;];
A_r=removerows(A, [1, 3])
A_r = ROWS 1
AND 3
NOW
5 6 7 REMOVED
2 6 9 FROM A!
Or you can use a manual way…
A=[ 1 2 4; Row 1 to row 3 and all
corresponding columns made
5 6 7; empty----hence removed!
8 9 0;
2 6 9;];
A( [1, 3] , : )=[ ]
A=
5 6 7 EXACT
SAME
2 6 9 RESULT!
To remove columns
>>magic(3)
8 1 6
3 5 7
4 9 2
Matrix1=magic(19);
Plot(Matrix1)
Magic(19)
400
350
300
250
200
150
100
50
0
0 2 4 6 8 10 12 14 16 18 20
Similarly magic(20) gives…..
400
350
300
250
200
150
100
50
0
0 2 4 6 8 10 12 14 16 18 20
Exercise
m=magic(5)
mm=removerows(m, [1, 2])
mm(:, 4:5)=[]
Switch statements- a substitute of if else statements
No input, no output.
Input(s), but no output.
No input but output(s).
No input, no output
function [ ]=hh( )
disp(‘I am a function')
End
function [ ]=my_func(a, b)
c=a+b;
Disp( c )
End
Call this function from your script or command window using this
command:
>> p=my_func (g, k)
NOTE:
If there are multiple outputs p, q and u, call your function like this:
>> [p q u]=my_func (g, k)
Exercise
Write a script. That script will take two input
integers from user.
Send them to a function that checks which integer
is greater, and it will return that integer.
Nested Loops
for i=1:1:5
if i==3
break;
end
disp(i)
end
Continue command
for i=1:1:5
if i==3
continue;
end
disp(i)
end
Remember this task from your prev assignment?