Check inversion of a square matrix

1 view (last 30 days)
I want o creat a binary square matrix (eg 3x3) with random number 0 and 1. Then calculate inverse of matrix. How do you check inverse of matrix by des and rank, if matrix don't have inverse then automatic back to the top of process? Thank for help me! I come from Viet nam

Accepted Answer

Walter Roberson
Walter Roberson on 5 Dec 2011

More Answers (1)

John D'Errico
John D'Errico on 5 Dec 2011
% generate a random binary matrix.
% M = rand(3) > 0.5; would also suffice
M = round(rand(3));
% The while loop will terminate when M is non-singular
while rank(M) < 3
M = round(rand(3));
end
  1 Comment
Nguyen
Nguyen on 5 Dec 2011
I do not understand steps 2, you can explain more clearly. Thank you and you can give me a example with a binary matrix 3 x 3 in matlab

Sign in to comment.

Categories

Find more on Random Number Generation 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!