필터 지우기
필터 지우기

Function Error not understood

조회 수: 1 (최근 30일)
Shalini
Shalini 2012년 3월 8일
I wrote the following function:
function diff = fit_simp(x,X,Y)
% This function is called by lsqnonlin.
% x is a vector which contains the coefficients of the
% equation. X and Y are the option data sets that were
% passed to lsqnonlin.
A=x(1);
B=x(2);
n=x(3);
diff = (A+B*(X^n)) - Y;
end
Then the following script;
>> X=xlsread('QS2T.xls',9,'V638:V1835');
>> Y=xlsread('QS2T.xls',9,'W638:W1835');
>> X0=[800 1537 0.1448];
>> options = optimset('Largescale','off');
>> x=lsqnonlin(@fit_simp,X0,[],[],options,X,Y);
I get the error below, don't know what is wrong. All this was given in matlab examples in the website.PLs help, *|??? Error using ==> mpower Matrix must be square.
Error in ==> fit_simp at 12 diff = (A+B*(X^n)) - Y;
Error in ==> lsqnonlin at 202 initVals.F = feval(funfcn{3},xCurrent,varargin{:});
Caused by: Failure in initial user-supplied objective function evaluation. LSQNONLIN cannot continue.|*

채택된 답변

Honglei Chen
Honglei Chen 2012년 3월 8일
You may want to use X.^n to achieve element-wise operation
  댓글 수: 7
Shalini
Shalini 2012년 3월 8일
I mean the error/warning: Maximum number of function evaluations exceeded;
How to increase this? I tried it by typing in the command line;
increase options.MaxFunEvals=60000 but does not help...??
Honglei Chen
Honglei Chen 2012년 3월 8일
this might suggest that the function didn't converge but I'm not sure what's wrong. You may need to examine your data.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by