Back to your question, I have to produce a random 3x3 matrix A that is invertible and display it. One way could be to start with a matrix that you know will have a determinant of zero and then add random noise to each element. It worked for me to generate random matrices that are invertable.
for MC = 1:10000
A = double(uint32(1000.*rand(3,1)).*uint32(1000.*rand(1,3)));
C = A + 100.0*rand(3,3);
if (rcond(C)<1e-20)
disp('algorithm fails');
C
inv(C)
end
end
There were objections to this suggestion about checking the determinant value. I had said: If the determinant of a square matrix is 0, it can't be inverted. I'd suggestion to test with - using your tolerance on the last argument. See comments below.
Best Answer