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

please write code on Matlab following above instructions (on the picture ) A06.3

ID: 3862279 • Letter: P

Question


please write code on Matlab following above instructions (on the picture )

A06.3 Diagonally dominant matrices #1 [4 marksl You might remember from the lectures that we derived a sufficient condition for convergence in the Gauss-Seidel method: if the coefficient ma x A is strictly diagonally dominant, then the method will converge, "strictly diagonally dominant" means that the absolute value of the diaganal element in each row is greater than the sum of the absolute values of all the other coefficients in the same row n mathematical terms, for i 2, write a script in Matlab to check whether a series of matrices are strictly diagonally dominant [3 marksl and display the results on screen using disp (1 mark Follow the comments in the template solution for hints and variable naming. Save your code to an m-file called "diagdom.m" and submit t to the Aa6 folder on Surrey Learn. Do not use external user defined functions.

Explanation / Answer

In MatLab first check a Series of Matrices are strictly diagonally dominant are not:

save as the Script in MatLab as diagdom.m

MatLab Script:

%size gives how many rows and columns in the A matrix
rowcol=size(A);
n=rowcol(1);
% count = counts the how many rows in that
% the absolute value of the diagonal element in a row is
% strictly greater than the sum of absolute value
% of the rest of the elements in that row
count=0;
for i=1:1:n
    sumrow=0;
    for j=1:1:n
        if i~=j
            sumrow=sumrow+abs(A(i,j));
        end
    end
    if abs(A(i,i))>sumrow
        count=count+1;
    end
end
disp('FIRST WAY')
if count==n
    disp('Matrix is strictly diagonal dominant')
else
    disp('Matrix is NOT strictly diagonal dominant')
end

Result:

FIRST WAY

Matrix is NOT strictly diagonal dominant