4*4 diagonally dominant matrix

6 views (last 30 days)
Lara de Vries
Lara de Vries on 2 Feb 2021
Answered: David Hill on 2 Feb 2021
Hello,
Im having trouble creating a diagonally dominant matrix. What command should i be using?
Thanks in advance!
  1 Comment
Daniel Pollard
Daniel Pollard on 2 Feb 2021
A diagonally dominant matrix is a pretty general thing. You could just call eye(4) and that would be (technically) diagonally dominant, although likely not that interesting.
What are you trying to do? What have you tried so far? Did you get any error messages, or unexpected outputs?

Sign in to comment.

Answers (1)

David Hill
David Hill on 2 Feb 2021
If you want to randomly generate, I would just generate a random 4x4 and then check whether it was diagonally dominant.
a=randi(100,4)-50;
while nnz(sum(abs(a),2)-2*diag(abs(a))>0)
a=randi(100,4)-50;
end

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!