필터 지우기
필터 지우기

How to tell if a random 3x3 Matrix is invertible

조회 수: 16 (최근 30일)
Kyle Donk
Kyle Donk 2020년 1월 10일
편집: Meg Noah 2020년 1월 11일
I have to produce a random 3x3 matrix A that is invertible and display it. I have a couple questions:
  1. How do I know when a matrix is invertible? I used the command (inv) on the random 3x3 matrix that I had created and I got a 3x3 matrix with different numbers. Does this mean that the matrix is invertible?
  2. I also got a hint with the question: Use a while-loop until you get one with non-zero determinant. I am confused by this because I used the determinants command (det) on my 3x3 matrix and got a nonzero determinant. I feel like I might be missing something here.
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 1월 10일
rank()
Most random matrices with floating point entries are invertible. Not all, but most. So unless you are using integer random values, do not be surprised if the first one you generate works.

댓글을 달려면 로그인하십시오.

채택된 답변

Meg Noah
Meg Noah 2020년 1월 10일
편집: Meg Noah 2020년 1월 11일
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
% first create a matrix that you know has a low rcond value:
A = double(uint32(1000.*rand(3,1)).*uint32(1000.*rand(1,3)));
% then add noise
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.
  댓글 수: 7
Steven Lord
Steven Lord 2020년 1월 11일
Better is simply to not invert a matrix. If you're trying to invert the matrix to solve a system of equations, use the backslash operator (\).
Meg Noah
Meg Noah 2020년 1월 11일
편집: Meg Noah 2020년 1월 11일
But that wasn't the question. He has a task to produce a matrix that can be inverted.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Switches and Breakers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by