solve函数使用问题。

16 Ansichten (letzte 30 Tage)
nefime
nefime am 24 Nov. 2022
Beantwortet: hefed am 24 Nov. 2022
为什么以下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来求解方程,该怎么做?

Akzeptierte Antwort

hefed
hefed am 24 Nov. 2022
第一种形式里,不含未知参数 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)

Weitere Antworten (0)

Kategorien

Mehr zu 编程 finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!