# Solving a system of multiple equations (including vector) for multiple variables

3 visualizaciones (últimos 30 días)
JC Chia el 27 de Oct. de 2020
Comentada: Divija Aleti el 2 de Nov. de 2020
I try to solve the equations to find the force acted on a suspension system of a car. Fn, Fcw and Fb are the forces acted upon the tyre. and F1-F5 is the force in the rods of the suspension system. In this calculation, i want to find the all the forces in the car's suspension system (in which the car is not moving). But my solution comes out to be 0x1 sym, how to I solve the problem? Thankss! (Sorry for the formatting, I no sure how to put it in better ways)
syms F1 F2 F3 F4 F5 FN Fcw Fb
A = table2array(PointCoordinates);
B = A';
B = B(:)';
Bc = mat2cell(B, 1, ones(1,27));
[X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3, X4, Y4, Z4, X5, Y5, Z5, X6, Y6, Z6, X7, Y7, Z7, X8, Y8, Z8, X9, Y9, Z9] = Bc{:};
[G, b, L] = deal(300, 702, 1560);
eqn1 = F1 + F2 + F3 + F4 + F5 + FN + Fb + Fcw == 0;
eqn2 = F1*[X1-X6,Y1-Y6,Z1-Z6]/norm([X1-X6,Y1-Y6,Z1-Z6]) + F2*[X2-X6,Y2-Y6,Z2-Z6]/norm([X2-X6,Y2-Y6,Z2-Z6]) + F3*[X3-X7,Y3-Y7,Z3-Z7]/norm([X3-X7,Y3-Y7,Z3-Z7])+ F4*[X4-X7,Y4-Y7,Z4-Z7]/norm([X4-X7,Y4-Y7,Z4-Z7]) + F5*[X5-X8,Y5-Y8,Z5-Z8]/norm([X5-X8,Y5-Y8,Z5-Z8]) + FN*[0,0,1] + Fb*[1,0,0] +Fcw*[0,1,0] ==0;
eqn3 = -F1*(Y1-Y6)/norm([X1-X6,Y1-Y6,Z1-Z6])*Z1 - F1*(Z1-Z6)/norm([X1-X6,Y1-Y6,Z1-Z6])*(Y1-Y9) - F2*(Y2-Y6)/norm([X2-X6,Y2-Y6,Z2-Z6])*Z1 - F2*(Z2-Z6)/norm([X2-X6,Y2-Y6,Z2-Z6])*(Y2-Y9)-F3*(Y3-Y7)/norm([X3-X7,Y3-Y7,Z3-Z7])*Z3 - F3*(Z3-Z7)/norm([X3-X7,Y3-Y7,Z3-Z7])*(Y3-Y9) - F4* (Y4-Y7)/norm([X4-X7,Y4-Y7,Z4-Z7])*Z4 - F4*(Z4-Z7)/norm([X4-X7,Y4-Y7,Z4-Z7])*(Y4-Y9)- F5*(Y5-Y8)/norm([X5-X8,Y5-Y8,Z5-Z8])*Z5 + F5*(Z5-Z8)/norm([X5-X8,Y5-Y8,Z5-Z8])*(Y5-Y9) ==0;
eqn4 = -F1*(X1-X6)/norm([X1-X6,Y1-Y6,Z1-Z6])*Z1 - F1*(Z1-Z6)/norm([X1-X6,Y1-Y6,Z1-Z6])*(X1-X9) + F2*(X2-X6)/norm([X2-X6,Y2-Y6,Z2-Z6])*Z2 + F2*(Z2-Z6)/norm([X2-X6,Y2-Y6,Z2-Z6])*(X2-X9)-F3*(X3-X7)/norm([X3-X7,Y3-Y7,Z3-Z7])*Z3 - F3*(Z3-Z7)/norm([X3-X7,Y3-Y7,Z3-Z7])*(X3-X9) + F4* (X4-X7)/norm([X4-X7,Y4-Y7,Z4-Z7])*Z4 + F4*(Z4-Z7)/norm([X4-X7,Y4-Y7,Z4-Z7])*(X4-X9)+ F5*(Z5-Z8)/norm([X5-X8,Y5-Y8,Z5-Z8])*(X5-X9) == 0;
eqn5 = FN == G*b/(2*L);
eqn6 = Fb == 0;
eqn7 = Fcw == 0;
sol = solve(eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7)
Results:
sol =
struct with fields:
F1: [0×1 sym]
F2: [0×1 sym]
F3: [0×1 sym]
F4: [0×1 sym]
F5: [0×1 sym]
FN: [0×1 sym]
Fb: [0×1 sym]
Fcw: [0×1 sym]
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Divija Aleti el 30 de Oct. de 2020
Hi,
If 'solve' returns empty objects ([0x1 sym]), then it means that no solutions exist for the given set of equations.
##### 2 comentarios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Z7)/norm([X4-X7,Y4-Y7,Z4-Z7])*(X4)+ F5*(Z5-Z8)/norm([X5-X8,Y5-Y8,Z5-Z8])*(X5) - F5*(X5-X8)/norm([X5-X8,Y5-Y8,Z5-Z8])*(Z5)== 0;
eqn5 = FN == G*b/(2*L);
eqn6 = (24602672183115776*F2)/117719838947027925 - (17699938183938048*F1)/58859785928570875 - (931698665586688*F3)/5307217631310225 + (6038517859745792*F4)/34546200184502645 - (4538783999459328*F5)/190649250609495925 == 0;
eqn7 = (53937642412179456*F1)/58859785928570875 + (110729617010065408*F2)/117719838947027925 + (5198765854031872*F3)/5307217631310225 + (6768593580589056*F4)/6909240036900529 + (115457517009502208*F5)/190649250609495925 == 0;
eqn8 = (30328928740573184*F5)/38129850121899185 - (6298002603900928*F2)/23543967789405585 - (104178726731776*F3)/1061443526262045 - (17051226323550208*F4)/172731000922513225 - (15553691486519296*F1)/58859785928570875 + FN == 0;
sol = solve(eqn6, eqn7, eqn8, eqn3, eqn4, eqn5)
sol =
struct with fields:
F1: [1×1 sym]
F2: [1×1 sym]
F3: [1×1 sym]
F4: [1×1 sym]
F5: [1×1 sym]
FN: [1×1 sym]
Finally I have a solution with 1x1 sym, but how to I actually know the number, I type F1 in command window it just give me F1 itself
Divija Aleti el 2 de Nov. de 2020
Hi,
The variable 'sol' is a struct. To access it's first element, type 'sol.F1'. To convert the resulting fraction into a decimal, type 'double(sol.F1)'
sol.F1
ans =
-1839148561728237595988134849563078234387089288058877419105564985640547230904797092698406326189288517452891162630896928337354030082617275/77354843129001923831027603919874732687274526293736826906292913237844237799289766460414626081744836930592865352742441940973046586146816
double(sol.F1)
ans =
-23.7755
Similary, you can access F2,F3,F4,F5 and FN.

Iniciar sesión para comentar.

### Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by