solve函数使用问题。

为什么以下solve函数不能等价?表达形式1:
>> [x,y] = solve('(x^2 + y^2)^(0.5)-((x-20)^2 + y^2)^(0.5) =0','(x^2 + y^2)^(0.5)-(x^2 + (y-20)^2)^(0.5) =0')
表达形式2:
>> a=0;b=0;>> [x,y] = solve('(x^2 + y^2)^(0.5)-((x-20)^2 + y^2)^(0.5) =a','(x^2 + y^2)^(0.5)-(x^2 + (y-20)^2)^(0.5) =b')
如果我要以表达形式2来求解方程,该怎么做?

 Accepted Answer

hefed
hefed on 24 Nov 2022

0 votes

第一种形式里,不含未知参数 a、b (或者说,你已经人为将参数a、b 换成了具体的数值)
第二种形式里,虽然你在 solve之前已经将参数 a、b 赋值了,但由于你的方程是 string 形式,参数值不会自动代入方程里,所以,你可以等方程求解出后,得到的解是关于 a、b 的表达式,然后通过 subs 函数,将参数 a、b 的数值代入。你也可以不通过subs 函数,只要将 string 形式的方程改成 symbolic 方程即可。方法如下:
a=0;b=0;
syms x y
[x,y] = solve((x^2 + y^2)^(0.5)-((x-20)^2 + y^2)^(0.5) -a,(x^2 + y^2)^(0.5)-(x^2 + (y-20)^2)^(0.5) -b)

More Answers (0)

Categories

Find more on 编程 in Help Center and File Exchange

Tags

Asked:

on 24 Nov 2022

Answered:

on 24 Nov 2022

Community Treasure Hunt

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

Start Hunting!