Solve system of nonlinear equations with matlab

4 ビュー (過去 30 日間)
Noa  Yelin
Noa Yelin 2020 年 10 月 19 日
コメント済み: Ameer Hamza 2020 年 10 月 19 日
how can i solve these 2 nonlinear equations in matlab?
−2𝑥^2+3𝑥𝑦+4sin (y)=6
3𝑥^2−2𝑥𝑦^2+3cos(𝑥)=−4
  1 件のコメント
Noa  Yelin
Noa Yelin 2020 年 10 月 19 日
Thank's to the answers

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

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 10 月 19 日
編集済み: Ameer Hamza 2020 年 10 月 19 日
One way is to use fsolve() from optimization toolbox
fun = @(x, y) [-2*x.^2+3*x.*y+4*sin(y)-6; ...
3*x.^2-2*x.*y.^2+3*cos(x)+4];
sol = fsolve(@(x) fun(x(1), x(2)), rand(1, 2));
x = sol(1);
y = sol(2);
Result
>> x
x =
0.5798
>> y
y =
2.5462
Note: due to periodic functions in you equations, there seems to be multiple solutions.
Another approach is to use vpasolve from symbolic toolbox
syms x y
eq1 = -2*x.^2+3*x.*y+4*sin(y)==6;
eq2 = 3*x.^2-2*x.*y.^2+3*cos(x)==-4;
eq = [eq1; eq2];
sol = vpasolve(eq);
x = sol.x;
y = sol.y;
  2 件のコメント
Noa  Yelin
Noa Yelin 2020 年 10 月 19 日
編集済み: Noa Yelin 2020 年 10 月 19 日
so i don't understand.. when I wrote this code-
syms x y
eq1 = -2*x.^2+3*x.*y+4*sin(y)==6;
eq2 = 3*x.^2-2*x.*y.^2+3*cos(x)==-4;
eq = [eq1; eq2];
sol = vpasolve(eq);
x = sol.x;
y = sol.y;
the output i get is -
x =
2.5921649161329924198470406781904
y =
2.0411522493463611320382918142382
is this correct?
Ameer Hamza
Ameer Hamza 2020 年 10 月 19 日
Yes, this is corect. These equations have multiple solutions.

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by