MATLAB: How can solve the nonlinear system of 6 equations with 6 unknown variables

6 equationsequations systemnonlinear

eq1 = a1+d1*d10+l*l10-p-b1;
eq2 = a2+d2*d20+l*l20-p-b2;
eq3 = a3+d3*d30+l*l30-p-b3;
eq4 = py+b*cos(psi)*sin(phi);
eq5 = -cos(theta)*sin(phi)+sin(psi)*sin(theta)*cos(phi)-cos(psi)*sin(phi);
eq6 = (b/2)*(cos(theta)*cos(phi)+sin(psi)*sin(theta)*sin(phi)-cos(psi)*cos(phi))-px;
% Solve the Equations
sol = solve(eq1,eq2,eq3,eq4,eq5,eq6);
sol.px
sol.py
sol.pz
sol.theta
sol.phi
sol.psi

Best Answer

No, you are trying to solve for a variable pz that does not occur in your equations.
Meanwhile, you indicate that you have 6 equations in 6 unknowns and you list 6 explicit unknowns, px, py, pz, theta, phi, psi, all of which occur only in the last 3 of your equations. We have to conclude that none of the names listed in the first 3 equations are symbolic because if they were there would be more than 6 unknowns available to be solved for. The first 3 equations must therefore be purely numeric, in which case you are asking solve() to solve for three numeric variables being equal to 0 and have all the symbolic information in the remaining 3 equations.
We notice the p in the first three equations and wonder whether it is related to px, py, pz. One possibility is that p = [px, py, pz]. But if that were the case then the first three equations would be vectors rather than single values and you would have 12 equations in 6 unknowns.
Perhaps your first three equations intended to reference one of px, py, pz each instead of p ?