MATLAB: I keep receiving the same error message when I try to get MATLAB to solve an AX=B matrix equation.

ax=bMATLABmatrix solversymbolic matrixvariable matrix

I am writing a code based on a force and moment balance of a design I have built, but since these values may change in the future all the expressions are in terms of variables and not specific quantities.
The code is the following:
syms Gx Gy; % substrate reaction force
syms Px Py; % shaft pin reaction force
syms Wl Wc g; % weight of light and cartridge+clamp as well as gravity
syms Sx Sy; % Spring force
syms k x; % spring constant and spring displacement
syms gamma alpha; % angle with respect to ground (-45 to 45) and angle with respect to spring (0 to 30)
syms Dgpx Dgpy % distance between point G and P for x and y axes
syms Dgsx Dgsy % distance between point G and S for x and y axes
syms Dpsx Dpsy % distance between point P and S for x and y axes
syms Dgwlx Dgwly % distance between point G and Wl for x and y axes
syms Dpwlx Dpwly % distance between point P and Wl for x and y axes
syms Dgwcx Dgwcy % distance between point G and Wc for x and y axes
syms Dpwcx Dpwcy % distance between point P and Wc for x and y axes
syms b1 b2 b3 b4; % variables for each value of the B vector in AX=B
% define matrix A: row 1 - sum of forces in y, row 2 - sum of forces in x,
% row 3 - sum of moments about G and row 4 - sum of moments about P
A = [1 1 0 0; 0 0 1 1; 0 -Dgpx 0 Dgpy; Dgpx 0 -Dgpy 0];
X = [Gy;Py;Gx;Px]; % define vector that will be solved
b1 = Sy+(Wl*g*cos(gamma))+(Wc*g*cos(gamma));
b2 = Sx-(Wl*g*sin(gamma))-(Wc*g*sin(gamma));
b3 = (Wl*g*(Dgwlx*cos(gamma)-Dgwly*sin(gamma)))-(Wc*g*(Dgwcx*cos(gamma)+Dgwcy*sin(gamma)))+(Sx*Dgsy)-(Sy*Dgsx);
b4 = (Wl*g*(Dpwlx*cos(gamma)-Dpwly*sin(gamma)))+(Wc*g*(Dpwcx*cos(gamma)-Dpwcy*sin(gamma)))+(Sx*Dpsy)-(Sy*Dpsx);
B = [b1;b2;b3;b4];
X = A\B;
disp(X);
When I run the code, I receive the following error message:
Warning: The system is inconsistent. Solution does not exist.
> In symengine
In sym/privBinaryOp (line 973)
In \ (line 365)
In KinematicModel (line 33)
Inf
Inf
Inf
Inf
I am not sure what the issue is, cause when I run disp(A) and disp(B) they both return the correct expressions.
Any help on this issue would be much appreciated!
Thanks.

Best Answer

A is only rank 3. You can isolate x1, x3, x2 but the 4th row will then become an equation that is independent of x4, and it is an expression that is not obviously true:
(Dgpy - Dgsy + Dpsy)*Sx + (Dgsx - Dgpx - Dpsx)*Sy + (Dgwcx*cos(gamma) - Dgpx*cos(gamma) + Dpwcx*cos(gamma) - Dgpy*sin(gamma) + Dgwcy*sin(gamma) - Dpwcy*sin(gamma))*g*Wc + (Dpwlx*cos(gamma) - Dgwlx*cos(gamma) - Dgpx*cos(gamma) - Dgpy*sin(gamma) + Dgwly*sin(gamma) - Dpwly*sin(gamma))*g*Wl == 0