Azzera filtri
Azzera filtri

I got warning while doing four bar mechanism analysis (Matrix is singular, close to singular or badly scaled)

1 visualizzazione (ultimi 30 giorni)
I get Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN
I try to do kinematic analysis for four bar mechanism, i used 12 constrain equation, contained 3 ground constrain, 8 join constrain, and 1 driving constrain. i use a jacobian of my constrain equation matrix. when run the code, i get thw warning says that my matrix is singular, close to singular, or badly scaled. i believe its refers to my jacobian matrix. I have checked my equation several times, but still dont know what is the problem. I follow the method in A. Shabana, Computational Dynamic to do computational kinematic analysis
Here is my input:
%Input
d = 27.5; %cm
l2 = 31; %cm
l3 = 37; %cm
l4 = 38.5; %cm
w2 = 2; %rad/s
teta2_o = pi/6; %rad
t = 0:0.001:2;
Numdata = size(t,2);
%Matrix coordinate
q = zeros(12,1);
q_all = zeros(12,Numdata);
qdot_all = zeros(12,Numdata);
qdot2_all = zeros(12,Numdata);
here is my constrain matrix and the jacobian
for j = 1:Numdata
for i = 1:3 %number of iteration
%Constrain matrix
C = [q(1); q(2); q(3);
q(4) - (l2*cos(q(6)))/2;
q(5) - (l2*sin(q(6)))/2;
q(4) + (l2*cos(q(6)))/2 - q(7) + (l3*cos(q(9)))/2;
q(5) + (l2*sin(q(6)))/2 - q(8) + (l3*sin(q(9)))/2;
q(7) - q(10) + (l4*cos(q(12)))/2;
q(8) - q(11) + (l4*sin(q(12)))/2;
q(10) + (l4*cos(q(12)))/2 - d;
q(11) + (l4*sin(q(12)))/2;
q(6) - teta2_o - w2*t(j)];
%Jacobian matrix
Cq = [1 zeros(1,11);
0 1 zeros(1,10);
0 0 1 zeros(1,9);
0 0 0 1 0 (l2/2)*sin(q(6)) zeros(1,6);
0 0 0 0 1 (-l2/2)*cos(q(6)) zeros(1,6);
0 0 0 1 0 (-l2/2)*sin(q(6)) -1 0 (-l3/2)*sin(q(9)) 0 0 0;
0 0 0 0 1 (l2/2)*cos(q(6)) 0 -1 (l3/2)*cos(q(9)) 0 0 0;
zeros(1,6) 1 0 0 -1 0 (-l4/2)*sin(q(12));
zeros(1,6) 0 1 0 0 -1 (l4/2)*cos(q(12));
zeros(1,9) 1 0 (-l4/2)*sin(q(12));
zeros(1,9) 0 1 (l4/2)*cos(q(12));
zeros(1,5) 1 zeros(1,6)];
here is one of the line, that mentioned in the warning
delta_q = inv(Cq)*(-C);
I hope someone can help me, thanks a lot.

Risposte (1)

Jaynik
Jaynik il 7 Mar 2024
Hi Fauzanul,
The warning you get suggests that the matrix "Cq" you're attempting to invert is either singular, close to singular, or badly scaled. This situation occurs when the matrix does not have a full rank, that is, there is not a unique solution to the system of equations, or the numerical values within the matrix lead to computational issues due to precision.
The condition number for matrix "Cq" calculated using the "cond" function gives the value 2.7105e+16. High condition numbers indicate that the matrix is close to singular, which can lead to significant numerical errors in computations. This is because small changes in the input can result in large changes in the output, making the system unstable. These are some steps that can be taken to address the issue:
  • Use the "pinv" function to compute the pseudo-inverse, which is more stable for ill-conditioned matrices.
  • Consider adding a small regularization term to the diagonal elements of your Jacobian matrix. This technique can help to stabilize the inversion but alters the original equations slightly. Here is a sample code for the same:
epsilon = 1e-10; % Small regularization factor
Cq_reg = Cq + epsilon*eye(size(Cq));
delta_q = Cq_reg\(-C);
  • Review the initial model and constraints and try to eliminate redundant constraints and reevaluate the initial conditions and the initial configuration.
  • For complex systems where high condition numbers are unavoidable, consider using specialized numerical methods. Techniques like singular value decomposition (SVD) can sometimes help in approaching the solution differently.
You can refer the following doc pages to read more about these functions:
Hope this helps!

Categorie

Scopri di più su General Applications in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by