How to solve a system of non linear equations with non-constant parameters?

1 次查看(过去 30 天)
I have a system of 2 non_linear (quadratic) equations:
x^2 - 2*a*x + a^2 + y^2 - 2*b*y + b^2 = r^2
x^2 - 2*c*x + c^2 + y^2 - 2*d*y + d^2 = r^2
where x,y are unknowns , and a,b,c,d,r are parameters that change in every iteration inside a loop.
I've tried to use the 'solve()' method , but I get an answer that is a function of the parameters and I need the real number solution.

回答(1 个)

Star Strider
Star Strider 2014-2-27
Use matlabFunction to create executable expressions:
syms a b c d r x y
[x, y] = solve(x^2 - 2*a*x + a^2 + y^2 - 2*b*y + b^2 == r^2, x^2 - 2*c*x + c^2 + y^2 - 2*d*y + d^2 == r^2);
x = simplify(collect(x));
y = simplify(collect(y));
xmf = matlabFunction(x)
ymf = matlabFunction(y)
Then use xmf and ymf (rename them if you want) in your loop.

类别

Help CenterFile Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by