Matrix is singular to working precision

197 views (last 30 days)
Amir Ahaki Lakeh
Amir Ahaki Lakeh on 8 Oct 2020
Answered: Alan Moses on 28 Oct 2020
When i run the below command the error is happen.
How should i do? i checked all things is oK but i dont know why the error occurs
%Computing heat flow in the bathroom floor
Edof=[1 1 2;
2 2 3;
3 3 4;
4 4 5;
5 5 6;
6 7 8;
7 9 10;
8 6 11;
9 11 12];
K=zeros(12);f=zeros(12,1);
f(3)=-30; f(4)=30;
ep1=[25];ep2=[250];ep3=[50];ep4=[6.66];ep5=[0.5];
ep6=[31.11];ep7=[6.25];ep8=[10.63];ep9=[7.7];
Ke1=spring1e(ep1);
Ke2=spring1e(ep2);
Ke3=spring1e(ep3);
Ke4=spring1e(ep4);
Ke5=spring1e(ep5);
Ke6=spring1e(ep6);
Ke7=spring1e(ep7);
Ke8=spring1e(ep8);
Ke9=spring1e(ep9);
K=assem(Edof(1,:),K,Ke1);
K=assem(Edof(2,:),K,Ke2);
K=assem(Edof(3,:),K,Ke3);
K=assem(Edof(4,:),K,Ke4);
K=assem(Edof(5,:),K,Ke5);
K=assem(Edof(6,:),K,Ke6);
K=assem(Edof(7,:),K,Ke7);
K=assem(Edof(8,:),K,Ke8);
K=assem(Edof(9,:),K,Ke9);
The temperature is prescribed in both
%air outside and air inside section of the floor which the temperatures are 22c
%and 5c respectively.The degree of freedom a1 and a12.
bc=[1 22;12 5];
%To solve the system for computing the temperature values T in the node points (given in (a)) and the boundary flows vector (r)we use function
%solveq.
[a,r]=solveq(K,f,bc);
Warning: Matrix is singular to working precision.
> In solveq (line 37)
In X9 (line 54)
%We use function extract to compute the temperatures of each element.
ed1=extract(Edof(1,:),a);
ed2=extract(Edof(2,:),a);
ed3=extract(Edof(3,:),a);
ed4=extract(Edof(4,:),a);
ed5=extract(Edof(5,:),a);
ed6=extract(Edof(6,:),a);
ed7=extract(Edof(7,:),a);
ed8=extract(Edof(8,:),a);
ed9=extract(Edof(9,:),a);
%The heat flow through each element is computed by using functions spring1s.
q1=spring1s(ep1,ed1);
q2=spring1s(ep2,ed2);
q3=spring1s(ep3,ed3);
q4=spring1s(ep4,ed4);
q5=spring1s(ep5,ed5);
q6=spring1s(ep6,ed6);
q7=spring1s(ep7,ed7);
q8=spring1s(ep8,ed8);
q9=spring1s(ep9,ed9);

Answers (1)

Alan Moses
Alan Moses on 28 Oct 2020
The warning “Matrix is singular to working precision” occurs if the matrix for which you are using to solve the system of linear equations is a singular matrix.
From your MATLAB script, line 37, which involves the solveq function has an input ‘K’ which is a singular matrix. Since the determinant of this matrix is zero, division by zero leads to computations with Inf and/or NaN, making the computed result unreliable. You can refer the same in this documentation under the “Examples” section.

Categories

Find more on Mathematics 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!