Solving system of quadratic equations
Show older comments
Hi guys!
I'm trying to solve a set of quadratic equations for a code I'm working on. I've tried to use vpasolve and solve but the code doesn't bring any solution. The equations are correct and I'm sure there are solutions to it as I can solve them with Mathematica but I'd like to be able to solve them in matlab so that I can write my code in there instead of Mathematica.
The code is something like this:
syms y1 y2 y3 y4 z1 z2
depd = [y1 y2 y3 y4 z1 z2];
% Assign the independent variables
x1 = sqrt(2/3);
x2 = sqrt(1/6);
x3 = sqrt(1/2);
x4 = sqrt(1/2);
z3 = sqrt(1/2);
z4 = sqrt(1/2);
prev = [-0.438450, -0.505030, -0.076748, -0.048791, 0.455646, 0.989215];
% write constraint equations
eq1 = (x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2 - 1/3 == 0;
eq2 = (x3 - x1)^2 + (y3 - y1)^2 + (z3 - z1)^2 - tan(pi/12) == 0;
eq3 = (x3 - x2)^2 + (y3 - y2)^2 + (z3 - z2)^2 - tan(pi/12) == 0;
eq4 = (y4 - x4)^2 + (z4 - y4)^2 + (x4 - z4)^2 - 1 == 0;
eq5 = (y4 - x1)^2 + (z4 - y1)^2 + (x4 - z1)^2 - 2 == 0;
eq6 = (z3 - x2)^2 + (x3 + y2)^2 + (y3 + z2)^2 - 0.84529946 == 0;
eqs = [eq1, eq2, eq3, eq4, eq5, eq6];
sol = vpasolve(eqs, depd, prev);
I don't need a precise solution but rather a numerical approximation. Is there something that can provide that in Matlab?
2 Comments
Matt J
on 11 Apr 2022
Are you sure the first equation shouldn't be,
eq1 = (x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2 - 1/3 == 0;
Alessandro Arduino
on 11 Apr 2022
Accepted Answer
More Answers (0)
Categories
Find more on Systems of Nonlinear Equations 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!