Matrix is singular to working precision.

3 Ansichten (letzte 30 Tage)
Sofia
Sofia am 11 Jul. 2024
Verschoben: Torsten am 11 Jul. 2024
I'm getting the error "Matrix is singular to working precision." I'm not sure what is wrong with my code but I need to not get zeros for my Total Stiffness Matrix, Nodal Forces, and Nodal Dispalcements. What should I do?
E = 200e9 * ones(2,1);
L = 2 * ones(2,1);
I = 3e-4 * ones(2,1);
kb = E.*I./L.^3;
q = 2e3; %---Positive for -y direction
f0 = q*[-L(2)/2;-L(2)^2/12;-L(2)/2;L(2)^2/12];
K = beam_stiffness(kb,L);
K(4:6,4:6)
ans = 3x3
0 0 0 0 0 0 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
d_part = K(4:6,4:6)\f0(2:end);
Warning: Matrix is singular to working precision.
d = [0;0;0;d_part];
f_eff = K * d;
f = f_eff - [0;0;-q*L(2)/2;-q*L(2)^2/12;-q*L(2)/2;q*L(2)^2/12];
t = zeros(size(L));
for cnt=1:length(L)
n{cnt} (1) = cnt;
n{cnt} (2) = cnt + 1;
end
function result = beam_stiffness(kb,l)
if ~(length(kb)==length(l))
error('Base stiffness and length arrays must have equal number of elements.');
end
num_elem = length(kb);
num_node = num_elem + 1;
ke = zeros(4,4,length(kb));
for cnt=1:num_elem
ke(:,:,cnt) = kb(cnt) * [12 6*l(cnt) -12 6*l(cnt);
6*l(cnt) 4*l(cnt)^2 -6*l(cnt) 2*l(cnt)^2;
-12 -6*l(cnt) 12 -6*l(cnt);
6*l(cnt) 2*l(cnt)^2 -6*l(cnt) 4*l(cnt)^2];
end
K = zeros(2*num_node,2*num_node);
for cnt=1:num_elem
K(2*cnt-1:2*cnt+2,2*cnt-1:2*cnt+2) - K(2*cnt-1:2*cnt+2,2*cnt-1:2*cnt+2) + ...
ke(:,:,cnt);
end
result = K;
end

Antworten (1)

Torsten
Torsten am 11 Jul. 2024
Verschoben: Torsten am 11 Jul. 2024
Obviously, your matrix is the zero matrix.
Most probably the reason is that you don't assign values to K in the loop
K(2*cnt-1:2*cnt+2,2*cnt-1:2*cnt+2) - K(2*cnt-1:2*cnt+2,2*cnt-1:2*cnt+2) + ...
ke(:,:,cnt);

Kategorien

Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by