Check inversion of a square matrix
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
More Answers (1)
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
See Also
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!