Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help write code on Matlab and check if this matrices can be made diagonal

ID: 3864948 • Letter: P

Question


please help write code on Matlab and check if this matrices can be made diagonally dominant

Solution u MATLAB Documentatio PLEASE DO NOT CLEAR THE WORKSPACE use the following 4 matrices (please do not change their values) A 11 4 0 1 1 1.5 9 -20 2; 15 1 4 5 1; 2 2 5 0 0 e 2 -3 1 -9 6 B m 19 3 3 12 3 2: 1 3 5 7 C- 1 13 2; 1 39 -12 2 -11; 8 5 -2 4 23 0 3 -1 -1: 3 3 9 .5; 1 1 1 5 1o The above natrices are not diagonally dominant so you don't have to 11 check them Do check whether they can be nade aiagonally daninant 12A Please use the following new matrices to store your results H A, M B, M C, M D. The above matrices will contain the diagonally domin ant matrix obtained from the 14 original one (A, B, Cor D) if they can be made so if not the 4 resulting matrices 15 will be simple copies of the original ones. 6 insert your code below) Reset You have 3 submissions remaining

Explanation / Answer

MATLAB Code:

%% Given Matrix
A=[1 2 0 1 1; -1 -5 9 -20 2; 15 1 4 5 1; 2 2 -5 0 0; 0 2 -3 1 -9];
B=[9 3 3;12 3 2;1 3 5];
C=[1 13 2; 1 3 9;-12 2 -1];
D=[5 -2 4 2; 0 3 -1 -1; 3 3 9 -5; 1 1 1 5];

%A=rand(3,3);
M_A=A;
M_A(eye(size(A))~=0)=0;
z=max([sum(M_A,1)' sum(M_A,2)],[],2);
M_A(eye(size(M_A))~=0)=z

M_B=B;
M_B(eye(size(B))~=0)=0;
z=max([sum(M_B,1)' sum(M_B,2)],[],2);
M_B(eye(size(M_B))~=0)=z

M_C=C;
M_C(eye(size(C))~=0)=0;
z=max([sum(M_C,1)' sum(M_C,2)],[],2);
M_C(eye(size(M_C))~=0)=z

M_D=D;
M_D(eye(size(D))~=0)=0;
z=max([sum(M_D,1)' sum(M_D,2)],[],2);
M_D(eye(size(M_D))~=0)=z

OUTPUT:

>> run_ddom

M_A =

16 2 0 1 1
-1 7 9 -20 2
15 1 22 5 1
2 2 -5 -1 0
0 2 -3 1 4


M_B =

13 3 3
12 14 2
1 3 5


M_C =

15 13 2
1 15 9
-12 2 11


M_D =

4 -2 4 2
0 2 -1 -1
3 3 4 -5
1 1 1 3