フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Solving non linear equation system.

1 回表示 (過去 30 日間)
Alberto Bolzoni
Alberto Bolzoni 2015 年 4 月 9 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I'm trying to solve this system:
sin(x)+y-2=0
x-y+1=0
with this procedure:
M=@(x,y)[sin(x)+y-2;x-y+1];
x0=[1,0];
Sol=fsolve(M,x0);
but I obtain an error. Could you please help me? Thank you.

回答 (1 件)

Michael Haderlein
Michael Haderlein 2015 年 4 月 9 日
fsolve needs a function which has only one variable. Therefore, you need to change your definition to
M=@(x)[sin(x(1))+x(2)-2;x(1)-x(2)+1];
The rest of your code is fine.
  3 件のコメント
Torsten
Torsten 2015 年 4 月 9 日
There is no such function in MATLAB because if you had a model with 150 unknowns, the alphabet wouldn't suffice to represent your variables.
Best wishes
Torsten.
Michael Haderlein
Michael Haderlein 2015 年 4 月 9 日
As Torsten said, there's no such function as far as I know. However, when I had the similar problem, I just typed in all the equations with the "natural" variable names in a blank file and then replaced the variable names by x(1), x(2) and so on (press ctrl+h). It's less likely to type in errors this way.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by