Having trouble with "Matrix is singular to working precision" error, would be glad if you help
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am very new to matlab and frankly to the math also, i was working for a company for a while but decide to start a master and thus the gap between my bachelor and master periods became long. Anyway I am trying to divide two matrix in matlab but it gives singularity error, i would be glad if you help, here are my matrices;
G =
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 2.3177 0 0.4011 -0.0966 0 0 0 0 0 0
0 0 0 0.0594 0.0966 -0.0223 0 0 0 0 0 0
0 0 0.4011 0.0966 2.3177 0 0.4011 -0.0966 0 0 0 0
0 0 -0.0966 -0.0223 0 0.0594 0.0966 -0.0223 0 0 0 0
0 0 0 0 0.4011 0.0966 2.3177 0 0.4011 -0.0966 0 0
0 0 0 0 -0.0966 -0.0223 0 0.0594 0.0966 -0.0223 0 0
0 0 0 0 0 0 0.4011 0.0966 2.3177 0 0.4011 -0.0966
0 0 0 0 0 0 -0.0966 -0.0223 0 0.0594 0.0966 -0.0223
0 0 0 0 0 0 0 0 0.4011 0.0966 1.1589 -0.1634
0 0 0 0 0 0 0 0 -0.0966 -0.0223 -0.1634 0.0297
>> L
L =
1.0e+04 *
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 6.3840 0 -3.1920 1.5960 0 0 0 0 0 0
0 0 0 2.1280 -1.5960 0.5320 0 0 0 0 0 0
0 0 -3.1920 -1.5960 6.3840 0 -3.1920 -1.5960 0 0 0 0
0 0 1.5960 0.5320 0 2.1280 -1.5960 0.5320 0 0 0 0
0 0 0 0 -3.1920 -1.5960 6.3840 0 -3.1920 1.5960 0 0
0 0 0 0 1.5960 0.5320 0 2.1280 -1.5960 0.5320 0 0
0 0 0 0 0 0 -3.1920 -1.5960 6.3840 0 -3.1920 1.5960
0 0 0 0 0 0 1.5960 0.5320 0 2.1280 -1.5960 0.5320
0 0 0 0 0 0 0 0 -3.1920 -1.5960 3.1920 -1.5960
0 0 0 0 0 0 0 0 1.5960 0.5320 -1.5960 1.0640
>> L/G Warning: Matrix is singular to working precision.
ans =
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
thank you for your help and sorry for my english
0 Kommentare
Antworten (3)
John D'Errico
am 5 Nov. 2017
As a guess, since a linear algebra divide makes no sense at all here (i.e., you never said anything about solving a linear system of equations) that you actually wanted to compute the ratio of corresponding elements.
r = L./G;
Yes, that will result in NaN elements where there were zeros. If you don't like NaNs, then do this at the end
r(isnan(r)) = 0;
0 Kommentare
David Goodmanson
am 5 Nov. 2017
Bearbeitet: David Goodmanson
am 5 Nov. 2017
Hi utkuzzz,
The command L/G is the same thing as L*inv(G), although computationally L/G is certainly the preferred way to do this. But G has no inverse, because it contains two rows and two columns of zeros. If you are not really concerned about the first two rows and columns, then you can eliminate them and get a result.
G3e = G(3:end,3:end);
L3e = L(3:end,3:end);
L3e/G3e
0 Kommentare
utkuzzz
am 5 Nov. 2017
3 Kommentare
David Goodmanson
am 7 Nov. 2017
Well, those are still not K and M since they can't have rows and columns of zeros, just as the example from the link does not. Their example does look a bit complicated.
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!