Warning: Matrix is singular to working precision.

5 vues (au cours des 30 derniers jours)
Brad Betty
Brad Betty le 31 Mai 2018
Modifié(e) : Jan le 31 Mai 2018
I'm trying to run a code and get this "Warning: Matrix is singular to working precision." when trying to compute my final matrix. I have posted the code below and I would be grateful if anyone could help me with it. Thank you
The line with "u = AreaMatrix\F_T;" is where the problem is.
% Initialsing given starting parameters
% Physical parameters
E = 71.7*10^9; % Modulus of elasticity (Pa)
rho = 2810; % Density of material (kg/m^3)
g = -9.81; % Acceleration due to gravity (ms^-2)
mass = [263 353 449]; % Vector contianing the masses to be tested (kg)
% [Empty Weight, One Passenger, Max Weight]
% Spatial parameters
L = 2.0225; % Size of landing gear (m)
w = 0.0826; % width of main strut beams (m)
xstart = 0; % Start of domain
xend = xstart + L; % End of domain
ne = 20; % Number of elements to be tested
% In order to postion plots for each subsequent loop and initial index needs to set.
% Setting this index
k = 1;
% Loop through the individual postions in the masses vector to plot the displacement and
% stress distributions in realtion to static loading.
for i = 1:length(mass)
% Constructing the grid in X
dx = (xend-xstart)/(ne); % Size of a single element
x = (xstart+dx):dx:xend; % Vector of node points from xstart to xend
% Initialising an array for the area which will alter with respect to each
% element
Area = zeros(1,ne);
% Loop through the number of elements being tested.
for n = 1:ne
% Determine and intialise the area which will vary according to the element
% position.
Area(n) = w*(L-x(n));
end
% Run through the number of elements compensating for the position of
% the upper and lower diagonals
for z = 1:ne-1
% Upper and lower diagonals
lower_diag(z) = -Area(z+1);
upper_diag(z) = -Area(z+1);
end
% Loop through the number of elements that is equal to the number of positions
% on the diagonal
for j = 1:ne
% Middle diagonal
if j~=ne
mid_diag(j) = Area(j)+Area(j+1);
else
mid_diag(j) = Area(j);
end
end
% Form a matrix using the above diagonal matrices,
% and multiply it by the modulus of elasticity divided by the element length
M = diag(mid_diag,0) + diag(lower_diag,-1) + diag(upper_diag,1);
AreaMatrix = (E/dx)*M;
% Initialise global load vector
Q = zeros(ne,1); % Global load vector
% Rationalising force components of the global vector this value is '0' as
% there are no body forces included this model.
q = 0;
% Loop through each number of elements to compute the comparative values of the
% load vector which will therefore be dependent on the size of each
% element provided.
for n = 1:ne
Q(n) = dx*q;
end
% Specify the final term of the global vector.
Q(end) = (dx*q)/2;
% Initialise the external force matrix.. This will consist of an array
% of zeros, with the final term being -mg, with this force being applied
% at x=L
R_L = zeros(ne,1);
R_L(end) = mass(i)*g;
% Add the body force and external force vectors to provide a sum of
% forces value(Force Total 'F_T") for further computation.
F_T = Q + R_L;
% Solve for the numerical solution of global displacement vector.
u = AreaMatrix\F_T;
% Loop through each number of elements to determine the stress. This is
% dependent on the displacement of the rear landing gear at each point
% required
for n = 1:ne
if n==1
stress(n) = E/dx*u(n);
else
stress(n) = E/dx*(u(n)-u(n-1));
end
end
% Plot the displacement of the landing gear
subplot(2, 3, k);
plot(x, u, 'gx', x, stress, 'bx')
xlabel('Length Along Landing Gear (m)')
ylabel('Displacement of Landing Gear (m)')
title(['Displacement of Landing Gear under ', num2str(mass(i)), 'kg']);
grid on;
% Plot the stress distribution of the landing gear below the displacement
% plots of their respective weights for comparison.
subplot(2,3,k+3);
plot(x, stress, 'rx')
xlabel('Length Along Landing Gear (m)')
ylabel('Stress (Pa)')
title(['Stress Distribution of Landing Gear under ', num2str(mass(i)), 'kg']);
grid on;
% Move to the next index for the subplot position
k = k+1;
end
  2 commentaires
Adam
Adam le 31 Mai 2018
Sounds like a problem that needs the domain knowledge of what you are doing rather than Matlab knowledge. You end up with a singular matrix. If you are not expecting one then it implies something is wrong with your calculations or if it is a valid result that you can end up with a singular matrix you would need to apply tricks to make it non-singular, such as adding a small value to the leading diagonal.
Stephen23
Stephen23 le 31 Mai 2018
@Brad Betty: you could start by reading some of the many posts on this perennially popular topic:

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 31 Mai 2018
Modifié(e) : Jan le 31 Mai 2018
The last row and column of AreaMatrix contain zeros only. The rank of this matrix is 19, while it is a 20x20 matrix. In consequence you cannot invert this matrix and condest(AreaMatrix) is Inf. This is the meaning of the warning message.
This happens, because Area(end) is zero, or because x(ne) equals L, such that w*(L-x(n)) is 0. It is not a problem of Matlab, but of the physical model.

Catégories

En savoir plus sur Stress and Strain dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by