フィルターのクリア

Errors in solving nonlinear simultaneous equations

1 回表示 (過去 30 日間)
Amit Kumar
Amit Kumar 2013 年 7 月 31 日
Hello all, I'm trying to solve nonlinear simultaneous equations. However, Matlab is giving errors, which I cannot rectify. Any help is much appreciated.
I made a function file:
function [ f ] = nlsimul( x)
%nlsimul has two nonlinear simultaneous equations in variable x(1), x(2)
f = [-2*(x(1).^2).*exp(-x(1).^2-(x(2).^2))+exp(-x(1).^2-(x(2).^2)); ...
-2.*x(1).*x(2)*exp(-x(1).^2-(x(2).^2))];
end
Then I made a script file to solve this system of equations:
%This script calles nlsimul() to solve nonlinear simultaneous equations
options = optimoptions('fsolve','Diagnostics','on','Display','iter','PlotFcns','@optimplotresnorm');
x0=[2,2];
[x,fval,exitflag,output] = fsolve(@nlsimul,x0,options)
Upon running this script file, Matlab gives several errors. Can someone help?

採用された回答

Sven
Sven 2013 年 7 月 31 日
編集済み: Sven 2013 年 7 月 31 日
You can't plot a simultaneous equation during iterations in that way.
If you instead put:
options = optimoptions('fsolve','Diagnostics','on','Display','iter');
Then your optimisation runs perfectly.
If you instead put (note the function handle rather than string):
options = optimoptions('fsolve','Diagnostics','on','Display','iter','PlotFcns',@optimplotresnorm);
Then it solves fine as well... it's too quick to see anything plotted though...
Did that help you out?
  1 件のコメント
Amit Kumar
Amit Kumar 2013 年 8 月 1 日
編集済み: Amit Kumar 2013 年 8 月 1 日
indeed helpful reply! thanks a lot!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by