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

3 Ansichten (letzte 30 Tage)
HONG CHENG am 10 Mai 2017
Beantwortet: Walter Roberson am 10 Mai 2017
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 ???
##### 1 KommentarKeine anzeigenKeine ausblenden
Star Strider am 10 Mai 2017

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Walter Roberson am 10 Mai 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...
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Functions 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!