Assignment Ikhlaq
Assignment Ikhlaq
Q.1. Create a symmetric matrix m with five rows and five columns. Calculate its
transpose and verify that the matrix is symmetric by observing that m=m.
Solution:
m=
5
1
2
3
7
2
3
7
3
2
3
7
3
2
1
7
3
2
1
5
>> m'
ans =
5
1
2
3
7
1
2
3
7
3
2
3
7
3
2
3
7
3
2
1
7
3
2
1
5
>> a=m-m'
%m=m
%m-m=0
a=
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Q.2. Create a random matrix with 3 rows and 5 columns. The matrix values should
be integer b/w (0100), than change its all 2 rows values by 7.
Solution:
a=randint(3,5,[0,100])
a=
65
82
66
34
29
34
53
73
31
84
57
37
a(1:2,1:5)=7
a=
7
7
61
7
7
76
7
7
82
7
7
79
7
7
17
10
>> c=[11:2:20]
c=
11
13
15
17
19
8
17
10
19
>> mat=[b ; c]
mat =
2
11
4
13
6
15
calculate
(a) c=d+e
(b) (b) c=d-e
(c) (c) c=d*e
(d) (d) c=d/e
(e) Note: multiplication and division should be done element
by element.
Solution:
clc
clear all
close all
d= [1+2j 3 ; 7
d=
% clears desktop
% Removes all variables and functions
% Closes all the open windows
5j ]
1.0000 + 2.0000i
7.0000
3.0000
0 + 5.0000i
5.0000 + 5.0000i
1.0000 - 8.0000i
c=d+e
c=
3.0000 + 5.0000i
7.0000
8.0000 + 5.0000i
1.0000 - 3.0000i
(b) c = d-e
d= [1+2j 3 ; 7
d=
5j ]
1.0000 + 2.0000i
3.0000
7.0000
0 + 5.0000i
2.0000 + 3.0000i
0
c=
-1.0000 - 1.0000i
7.0000
5.0000 + 5.0000i
1.0000 - 8.0000i
c=d+e
(c) c=d*e
d= [1+2j 3 ; 7
5j ]
-2.0000 - 5.0000i
-1.0000 +13.0000i
d=
1.0000 + 2.0000i
7.0000
3.0000
0 + 5.0000i
2.0000 + 3.0000i
0
5.0000 + 5.0000i
1.0000 - 8.0000i
c=
-4.0000 + 7.0000i
0
15.0000 +15.0000i
40.0000 + 5.0000i
c=d*e
(d) c=d/e
d= [1+2j 3 ; 7
d=
5j ]
1.0000 + 2.0000i
7.0000
3.0000
0 + 5.0000i
2.0000 + 3.0000i
0
5.0000 + 5.0000i
1.0000 - 8.0000i
% clears desktop
% Removes all variables and functions
% Closes all the open windows
% Time for given function will be
% Generating the function
% plotting the signal
% Labeling the X-axis
ylabel ('Amplitude')
% Labeling the Y-axis
% start grid On