Warning: Matrix is singular to working precision.
1 view (last 30 days)
Show older comments
I'm trying to solve a system of equations using matlabs backslash function for matrices but I keep getting the error that my matrix is singular. How can I fix this? My matrix (M) is 21X21 and i'm sure there are no columns or rows that have only zeros.
M=zeros(3*NNodes,2*NNodes);
RHS=-NodeF(:)
for i=1 :Nelements
N1=Elmt(i,1);
N2=Elmt(i,2);
R=NodeR(N2,:)-NodeR(N1,:); unit=R/sqrt(R(1)^2+R(2)^2+R(3)^2);
M(3*N1-2,i)=unit(1);
M(3*N1-1,i)=unit(2);
M(3*N1,i)=unit(3);
M(3*N2-2,i)=-unit(1);
M(3*N2-1,i)=-unit(2);
M(3*N2,i)=-unit(3);
end
% Now we deal with the boundary conditions for i=1:NBdry; N=BdryNodes(i); unit=BdryDir(i,:); M(3*N-2,Nelements+i)=unit(1); M(3*N-1,Nelements+i)=unit(2); M(3*N,Nelements+i)=unit(3); end Forces=M\RHS;
Not sure if that helps but thanks anyway
1 Comment
Torsten
on 29 Oct 2015
How can your matrix be (21x21) if it is created as
M=zeros(3*NNodes,2*NNodes);
?
Best wishes
Torsten.
Answers (1)
John D'Errico
on 28 Oct 2015
So, without telling us what you are doing, we need to guess what this matrix represents? You have not even given us sufficient information to create the matrix itself. The crystal ball is so foggy today.
My initial guess is that it represents a stiffness matrix, for a finite element problem of some ilk.
You need to recognize that the potential energy does not change under translation, rotation, etc., so this MAY be your issue. But how can I read your mind? All you have shown us is a code fragment of unexecutable, uncommented code.
0 Comments
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!