how to solve two equation with 2 variables

1 回表示 (過去 30 日間)
Adham Ahmed
Adham Ahmed 2023 年 2 月 16 日
編集済み: Matt J 2023 年 2 月 16 日
how to solve these two equations :
sin(x2) +2x2 =0
sin(x1-1)+2(x1-1)=0

採用された回答

Matt J
Matt J 2023 年 2 月 16 日
編集済み: Matt J 2023 年 2 月 16 日
You could use fsolve or fminsearch
fun=@(x) [sin(x(2))+2*x(2); sin(x(1)-1)+2*(x(1)-1)];
[x,fval]=fsolve(fun,[0;0])
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
x = 2×1
1 0
fval = 2×1
0 0
[x,fval]=fminsearch(@(x) norm(fun(x)), [0,0])
x = 1×2
1.0000 -0.0000
fval = 9.4426e-05

その他の回答 (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