Solving a system of 4 non-linear equations with 4 unknowns
Show older comments
I have the following system of equations to solve:

Where mr1=3.643*10^-3, mr2=3.561*10^-3, mr3=3.243*10^-3, and mr4=2.806*10^-3. L1=0, L2=110, θ1=0, and θ2=100.
I've been trying to solve this for a while now, but I have no idea how to go about it. I don't know how to get matlab to solve for the unknowns, and I can't seem to get it to accept any variables as unknowns.
EDIT: I've managed to get something to work properly for the first two equations, but the last two give me extremely wrong answers. I should be getting something around L3=-14.16 and L4=141.8, which are the values I got experimentally, but nothing I do seems to work that way. The code I used is as follows:
global mr a1 a2 L1 L2 a3 a4
mr=[3.643E-03;3.561E-03;3.243E-03;2.806E-03];
L1=0;
L2=110;
a1=0;
a2=100;
x0=[190;270];
[x,fval]=fsolve(@calcs,x0,optimset('MaxFunEvals', 90000, 'MaxIter', 10000, 'FunValCheck', 'on', 'PlotFcns', @optimplotfval));
a3=x(1)
a4=x(2)
x0=[0.0150;0.1710]
[x,fval]=fsolve(@calcs2,x0,optimset('MaxFunEvals', 90000, 'MaxIter', 10000, 'FunValCheck', 'on', 'PlotFcns', @optimplotfval));
L3=x(1)
L4=x(2)
function F=calcs(x)
global mr a1 a2
F=[(mr(1)*cos(a1))+(mr(2)*cos(a2))+(mr(3)*cos(x(1)))+(mr(4)*cos(x(2)));
(mr(1)*sin(a1))+(mr(2)*sin(a2))+(mr(3)*sin(x(1)))+(mr(4)*sin(x(2)))];
end
function F=calcs(x)
global mr a1 a2 L1 L2 a3 a4
F=[((mr(2)*cos(a2))*L2)+((mr(3)*cos(a3))*x(1))+((mr(4)*cos(a4))*x(2));
((mr(2)*sin(a2))*L2)+((mr(3)*sin(a3))*x(1))+((mr(4)*sin(a4))*x(2))];
end
Answers (1)
Walter Roberson
on 30 Mar 2018
0 votes
fsolve() with anonymous functions, or use syms and solve() the symbolic expressions.
Categories
Find more on Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!