Error using inv Matrix must be square
4 views (last 30 days)
Show older comments
So im pretty new to mathlab can someone just guide me and tell me what i am missing?
B =
0.0000 - 7.5700i 0.0000 + 3.3300i 0.0000 + 0.0000i 0.0000 + 3.3300i 0.0000 - 1.3600i
0.0000 + 3.3300i 0.0000 -16.6600i 0.0000 + 3.3300i 0.0000 +10.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 3.3300i 0.0000 - 7.7100i 0.0000 + 3.3300i 0.4100 - 1.5200i
0.0000 + 3.3300i 0.0000 +10.0000i 0.0000 + 3.3300i -17.6600 + 0.0000i -0.9000 - 1.2000i
>> inv(B) Error using inv Matrix must be square.
0 Comments
Answers (1)
Stephen23
on 7 Apr 2015
Edited: Stephen23
on 7 Apr 2015
>> B = [0-7.57i, 0+3.33i, 0+0.00i, 0+3.33i, 0-1.36i;...
0+3.33i, 0-16.66i, 0+3.33i, 0+10.i, 0.00+0.i;...
0+0.00i, 0+3.33i, 0-7.71i, 0+3.33i, 0.41-1.52i;...
0+3.33i, 0+10.i, 0+3.33i, -17.66+0.i, -0.90-1.20i];
>> size(B)
ans =
4 5
So the matrix is clearly not square. And yet the matrix inverse operation is only defined for square matrices: "inv(X) returns the inverse of the square matrix X" states the documentation clearly.
Every source you will care to look at will tell you that a matrix must be square to be invertable: "In linear algebra, an n-by-n square matrix A is called invertible..."
3 Comments
Stephen23
on 7 Apr 2015
Edited: Stephen23
on 8 Apr 2015
@Marvin Castellanos: when you can tell us what the inverse of a non-square matrix is, then we will show you how to code it.
There are some situations where a left / right inverse might be possible: "Non-square matrices (m-by-n matrices for which m ≠ n) do not have an inverse. However, in some cases such a matrix may have a left inverse or right inverse. If A is m-by-n and the rank of A is equal to n, then A has a left inverse: an n-by-m matrix B such that BA = I. If A has rank m, then it has a right inverse: an n-by-m matrix B such that AB = I."
Quoted from
But then you will need to tell us more about your matrix before we can tell you if this is possible.
See Also
Categories
Find more on Linear Algebra 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!