Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 ???

Risposte (1)

Walter Roberson
Walter Roberson il 10 Mag 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...

Categorie

Scopri di più su Function Creation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by