Solving an equation with two variables, why is one being set to zero?

1 次查看(过去 30 天)
My code is as follows:
syms x y
[xRoot, yRoot] = solve((y-1).^2 + (x-1).^2 == floor(sqrt(2)-1).^2,y,x)
The output of this should (hopefully) be xRoot = 1, yRoot = 1 however in the actual output yRoot is being set to zero and xRoot is 1+-i.
How can I stop yRoot being set to zero and therefore not get complex roots for x?
Thanks.

采纳的回答

John D'Errico
John D'Errico 2017-9-28
There are multiple solutions here. This will help in your case though.
syms x y real

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by