Question

1. An n x n matrix is said to be diagonally dominant if , lail for i = 1,...,n ji Basically, if for every row, the absolute v

Please answer through MATLAB and show WHOLE script.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB code:

%----------------------

function result = dominant(A)
% matrix dimensions
d = size(A);
% for loop over rows
for i = 1:d
% sum of row elements except diagonal element
sum_row =0;
% for loop over columns
for j = 1:d
% adding each elements to sum variable
sum_row = sum_row+ abs(A(i,j));
end
%subratcting diagonal element
sum_row = sum_row-abs(A(i,i));
%checking dominant condition
% failed once means matrix is not diagonal dominant
if abs(A(i,i))< sum_row
result = 'false';
return;
end
end

% dominant condition not failed
result = 'true';
end

% matrix A
A = [ 3 -2 1; 1 -3 2; 1 2 6]

% result
result = dominant(A)

% matrix A
A = [ -2 1 2; 1 3 2; 1 -2 0]

% result
result = dominant(A)

%----------------------

Output:

A = 3 1 1 -2 -3 2 Nm 1 2 6 result = true A = -2 - 1 3 1 -2 1 2 2 o result = false

Code snippet:

function result = dominant(A) % matrix dimensions d = size(A); % for loop over rows for i = 1:0 % sum of row elements except

Add a comment
Know the answer?
Add Answer to:
Please answer through MATLAB and show WHOLE script. 1. An n x n matrix is said...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • answer 8 using matlab Using nested loops, traverse through the matrix for the following. a) Replace...

    answer 8 using matlab Using nested loops, traverse through the matrix for the following. a) Replace all elements divisible by 3 with 100. b) Replace all elements divisible by 2 with 50. c) Replace the first element of each row with 10. d) Display the all elements of the 2D matrix as a 10 array (9 elements in 1 row) 8) Write a function file that determines the maximum element of an input matrix A using nested loops and counts...

  • matlab( answer the question in matlab) show the full answer with comment please. W a rnction...

    matlab( answer the question in matlab) show the full answer with comment please. W a rnction to find the largest product of adjacent number pairs in a matrix, where pair combinations can be selected the horsonal accent or vertically adjacent (but not diagonally adjacent) of numbers in a matrix are accent if they are in the same row or column and located next to each other when the 2D matrix is displayed The largest product of a pair of adjacent...

  • Please answer 1c, use MATLAB, and paste your entire script in your answer so that I...

    Please answer 1c, use MATLAB, and paste your entire script in your answer so that I can copy and paste to see if it works. Problem #1 400g triangle square pentagon hexagon Figure 1 For a closed geometric figure composed of straight lines (Figure 1), the interior angles in the figure must add to (n-2)(180) where n is the number of sides. Required Tasks a) Write a script that prompts the user to select from one of the following shapes:...

  • (1 point) The trace of a square n x n matrix A = (aii) is the...

    (1 point) The trace of a square n x n matrix A = (aii) is the sum ani + 022 + ... + ann of the entries on its main diagonal. Let V be the vector space of all 2 x 2 matrices with real entries. Let H be the set of all 2 x 2 matrices with real entries that have trace 1. Is Ha subspace of the vector space V? 1. Does H contain the zero vector of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT