Having trouble with "Matrix is singular to working precision" error, would be glad if you help
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (3개)
John D'Errico
2017년 11월 5일
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
David Goodmanson
2017년 11월 5일
편집: David Goodmanson
2017년 11월 5일
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
utkuzzz
2017년 11월 5일
댓글 수: 3
David Goodmanson
2017년 11월 7일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!