フィルターのクリア

Solve nonlinear equations within range

9 ビュー (過去 30 日間)
Stephen
Stephen 2018 年 10 月 17 日
編集済み: Matt J 2018 年 10 月 19 日
Hello,
I have two nonlinear equations to solve simultaneously:
syms x, y
f1 = x^2 + y^2 + x == 4
f2 = x^3 + y*2 == 2
I want to find the solutions (if there's any), when x belongs to the range of [-1,1]. And I don't want to make another matlab file whose purpose is to group the above equations. Because most of the time, the equations are derived from the using symbolic tools earlier in same matlab script and it would be inconvenient to make a separate file.
In this case, what is the way to achieve my goal?
Thanks in advance.
Steph

採用された回答

Matt J
Matt J 2018 年 10 月 17 日
syms x y
assume(x>=-1 & x<=1)
f1 = x^2 + y^2 + x == 4
f2 = x^3 + y*2 == 2
[solx,soly]=vpasolve(f1,f2,x,y)
  8 件のコメント
Stephen
Stephen 2018 年 10 月 19 日
編集済み: Stephen 2018 年 10 月 19 日
Isn't that function is supposed to be used for curve fitting?
How do I convert those two non-linear equations so that I can use lsqnonlin?
Matt J
Matt J 2018 年 10 月 19 日
編集済み: Matt J 2018 年 10 月 19 日
Example:
fun=@(p) [p(1)^2+p(2)^2+p(1)-4; p(1)^2+2*p(2)-2];
[p,resnorm,~,exitflag]=lsqnonlin(fun,[0,0],[-3,-inf],[+3,+inf])
if resnorm>TOO_BIG
warning 'The result does not satisfy equations well.'
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by