Professional Documents
Culture Documents
matrix. Then define other matrix i.e. 3x3 as an I matrix and applied the I matrix
to previous matrix.
A=[1:1:4;2:2:8]
A=
1 2 3 4
2 4 6 8
vect=[10:4:22]
vect =
10 14 18 22
A(3,:)=vect
A=
1 2 3 4
2 4 6 8
10 14 18 22
I=eye([3,3])
I=
1 0 0
0 1 0
0 0 1
C=[A I]
C=
1 2 3 4 1 0 0
2 4 6 8 0 1 0
10 14 18 22 0 0 1
20) Create a square matrix with elements of vector [7,4,2] in diagonal.
I=eye([3,3])
I=
1 0 0
0 1 0
0 0 1
vect=[7 4 2]
vect =
7 4 2
I=diag(vect)
I=
7 0 0
0 4 0
0 0 2
21) Create a vector from diagonal element of the matrix given below.
A=
1 2 3
4 5 6
7 8 9
vect=diag(A)
vect =
1
5
9
22) Create the following matrix.
C=[2:2:10;3:3:15;7:7:35]
C=
2 4 6 8 10
3 6 9 12 15
7 14 21 28 35
(i) Create a 3 column vector named as Va that contains elements of 3rd column
of C matrix
Va =C(:,3)
Va =
6
9
21
Vb =C(2,:)'
Vb =
3
6
9
12
15
(iii) Create a 9 column element vector named as Vc that contains 1st ,3rd ,5th
column of C.
Vc =C(:,[1,3,5])
Vc =
2 6 10
3 9 15
7 21 35
(iv) Create 10 element column vector Vd that contains all elements of 1st and 2nd
row of C matrix.
D=C([1:2],:)
D=
2 6 10
3 9 15
23) Let vector A[8 5 4],vector B=[10 2 7].Calculate A+B,A-B and check [A*B],
[A.*B]
A=[8 5 4]
A=
8 5 4
B=[10 2 7]
B=
10 2 7
C=A+B
C=
18 7 11
C=A-B
C=
-2 3 -3
C=A*B
??? Error using ==> mtimes
Inner matrix dimensions must agree.
C=A.*B
C=
80 10 28
24) Define 2x3 matrix add them, subtract them and calculate addition result-8.
A=[2:2:6;5:10:25]
A=
2 4 6
5 15 25
B=[5 6 7;7 8 9]
B=
5 6 7
7 8 9
C=A+B
C=
7 10 13
12 23 34
C=A-B
C=
-3 -2 -1
-2 7 16
A+B-8
ans =
-1 2 5
4 15 26
Q 2) DOUBLE UNDERLINE KEY.
Sol.)
COMPUTER FUNDAMENTAL
Q.3) CHANGE BACKGROUND COLOUR
TO YELLOW AND TEXT COLOUR
TO BLUE .
Q 4) USE STRIKE THROUGH THE TEXT
COMPUTER FUNDAMENTALS
COMPUTER FUNDAMENTALS