unable to use solve or fsolve for linear system
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dhanush Srikanth
el 26 de Jun. de 2022
Comentada: Dhanush Srikanth
el 26 de Jun. de 2022
syms R1 R2 R3 R4
COM = [-6,0,10]
r1 = [-54.2,-27.5,-16.4]
r2 = [-54.2,27.5,-16.4]
r3 = [42.9,-27.5,-16.4]
r4 = [42.9,27.5,-16.4]
rr1 = [0,0,R1]
rr2 = [0,0,R2]
rr3 = [0,0,R3]
rr4 = [0,0,R4]
mg = [0,0,980.65*16631]
eq(1) = cross(r1-r2,rr2) + cross(r1-r3,rr3) + cross(r1-COM,mg) + cross(r1-r4,rr4) == [0,0,0]
eq(2) = cross(r2-r1,rr1) + cross(r2-r3,rr3) + cross(r2-COM,mg) + cross(r2-r4,rr4) == [0,0,0]
eq(3) = cross(r3-r2,rr2) + cross(r3-r1,rr1) + cross(r3-COM,mg) + cross(r3-r4,rr4) == [0,0,0]
eq(4) = cross(r4-r2,rr2) + cross(r4-r3,rr3) + cross(r4-COM,mg) + cross(r4-r1,rr1) == [0,0,0]
j = fsolve(eq,[R1,R2,R3,R4])
im trying to solve the above system of linear equations for R1 R2 R3 & R4
the error is
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
C = privsubsasgn(L,R,inds{:});
0 comentarios
Respuesta aceptada
Torsten
el 26 de Jun. de 2022
Editada: Torsten
el 26 de Jun. de 2022
Seems your equations are not independent.
syms R1 R2 R3 R4
COM = [-6,0,10];
r1 = [-54.2,-27.5,-16.4];
r2 = [-54.2,27.5,-16.4];
r3 = [42.9,-27.5,-16.4];
r4 = [42.9,27.5,-16.4];
rr1 = [0,0,R1];
rr2 = [0,0,R2];
rr3 = [0,0,R3];
rr4 = [0,0,R4];
mg = [0,0,980.65*16631];
%eq(1) = cross(r1-r2,rr2) + cross(r1-r3,rr3) + cross(r1-COM,mg) + cross(r1-r4,rr4) == [0,0,0]
%eq(2) = cross(r2-r1,rr1) + cross(r2-r3,rr3) + cross(r2-COM,mg) + cross(r2-r4,rr4) == [0,0,0]
%eq(3) = cross(r3-r2,rr2) + cross(r3-r1,rr1) + cross(r3-COM,mg) + cross(r3-r4,rr4) == [0,0,0]
%eq(4) = cross(r4-r2,rr2) + cross(r4-r3,rr3) + cross(r4-COM,mg) + cross(r4-r1,rr1) == [0,0,0]
%j = fsolve(eq,[R1,R2,R3,R4])
cross(r1-r2,rr2) + cross(r1-r3,rr3) + cross(r1-COM,mg) + cross(r1-r4,rr4)
cross(r2-r1,rr1) + cross(r2-r3,rr3) + cross(r2-COM,mg) + cross(r2-r4,rr4)
cross(r3-r2,rr2) + cross(r3-r1,rr1) + cross(r3-COM,mg) + cross(r3-r4,rr4)
cross(r4-r2,rr2) + cross(r4-r3,rr3) + cross(r4-COM,mg) + cross(r4-r1,rr1)
A = [0 -55 0 -55;55 0 55 0; 0 0 97.1 97.1;-97.1 -97.1 0 0];
rank(A)
b = [3588021833/8;-3588021833/8;-1648577405738025/2097152;836259700628521/1048576];
sol = A\b;
R1 = sol(1)
R2 = sol(2)
R3 = sol(3)
R4 = sol(4)
Más respuestas (1)
Walter Roberson
el 26 de Jun. de 2022
those cross() calls each return a vector, and you compare the vector to [0 0 0] giving a vector result. You then try to store the vector in a scalar location.
If you were to store the entire vector, then when you got to the fsolve you would have four sets of 3 equations, for a total of 12 equations. And you are trying to fsolve the 12 for four variables. That is unlikely to succeed.
Ver también
Categorías
Más información sobre Matrices and Arrays 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!