# Errors in solving nonlinear simultaneous equations

조회 수: 1(최근 30일)
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.
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 2013년 7월 31일
편집: Sven 2013년 7월 31일
You can't plot a simultaneous equation during iterations in that way.
options = optimoptions('fsolve','Diagnostics','on','Display','iter');
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...
##### 댓글 수: 1표시 없음숨기기 없음
Amit Kumar 2013년 8월 1일
편집: Amit Kumar 2013년 8월 1일

댓글을 달려면 로그인하십시오.

### 범주

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by