How to calculate the equation with letters and 2 variables to get just one solution

6 views (last 30 days)
Dear everyone,
I want to calculate an equation with letter and variable.
Now I can get the variable value presented with the letters I used
but I don't know how to change the letters as real numbers.
this is the example
syms x0 y0 x1 y1 x2 y2 a b p q d positive;
[x0 y0] = solve('(x-p)^2+(y-q)^2=d^2','(p-a)*(y-b)=(x-a)*(q-b)')
then I can get the result
but the problem is how to enter the real number value of letters like
a = 1;
b = 2;
p = 3;
q = 4;
d = 5;
then how to get the only one solution for this two equation ???

Answers (1)

Walter Roberson
Walter Roberson on 10 May 2017
syms x y a b p q d positive;
sol = solve((x-p)^2+(y-q)^2==d^2, (p-a)*(y-b)==(x-a)*(q-b), 'returnconditions', true);
a = 1;
b = 2;
p = 3;
q = 4;
d = 5;
condition_information = arrayfun(@(C) solve(C,sol.parameters, 'returnconditions', true), subs(sol.conditions));
acceptable_solutions = ~cellfun(@isempty, {ttt.conditions});
x = subs(sol.x(acceptable_solutions));
y = subs(sol.y(acceptable_solutions));
Note: the code can be shorter if you do not mind nasty long warning messages...

Community Treasure Hunt

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

Start Hunting!