Docsity

Matrix Operations and Manipulation, Summaries of Engineering

Toggle sidebar
bg1
(a) Make a matrix M1 which consists of two rows and three columns and all the entries in the
matrix are ones.
(b) Make a vector V1 consisting of three ones.
(c) Make a 3x3 matrix M2 in which the diagonal entries are all fives.
(d) Now make a matrix M3 from M1, M2 and V1 which look like the matrix given below
M3=
1 1 1
1 1 1
0 0 0
5 0 0
0 5 0
0 0 5
Creating matrix M1
M1 = ones(2, 3);
% Creating vector V1
V1 = ones(3, 1);
% Creating matrix M2 with diagonal entries as fives
M2 = 5 * eye(3);
% Creating matrix M3 using M1, M2, and V1
M3 = [M1; M2(1:2, ; zeros(1, 3)];
% Displaying the result
Disp(‘Matrix M3:’);
Disp(M3);
(e) Now use the referencing element concept to make three vectors V2, V3 and V4 such that V2
consists of first row of M3, V3 consists of second row of M3 and V4 consists of third row of M3.
(f) Now alter the fourth entry of vectors V2, fifth entry of V3 and sixth entry of V4 to 1.4 and
make a new vector M4 which looks like the matrix given below.
M4=
1 1 1
1 1 1
0 0 0
1.4 0 0
0 1.4 0
0 0 1.4

Partial preview of the text

Download Matrix Operations and Manipulation and more Summaries Engineering in PDF only on Docsity!

(a) Make a matrix M1 which consists of two rows and three columns and all the entries in the matrix are ones. (b) Make a vector V1 consisting of three ones. (c) Make a 3x3 matrix M2 in which the diagonal entries are all fives. (d) Now make a matrix M3 from M1, M2 and V1 which look like the matrix given below M3=

Creating matrix M M1 = ones(2, 3); % Creating vector V V1 = ones(3, 1); % Creating matrix M2 with diagonal entries as fives M2 = 5 * eye(3); % Creating matrix M3 using M1, M2, and V M3 = [M1; M2(1:2, ; zeros(1, 3)]; % Displaying the result Disp(‘Matrix M3:’); Disp(M3); (e) Now use the referencing element concept to make three vectors V2, V3 and V4 such that V consists of first row of M3, V3 consists of second row of M3 and V4 consists of third row of M3. (f) Now alter the fourth entry of vectors V2, fifth entry of V3 and sixth entry of V4 to 1.4 and make a new vector M4 which looks like the matrix given below. M4=