フィルターのクリア

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

2 ビュー (過去 30 日間)
HONG CHENG
HONG CHENG 2017 年 5 月 10 日
回答済み: Walter Roberson 2017 年 5 月 10 日
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 件)

Walter Roberson
Walter Roberson 2017 年 5 月 10 日
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...

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by