Debugging a code for fitting an anonymous function

Hi,
I wrote the following code to estimate model parameters A and B while fitting dependent data IR to independent data Ipar. IRmax is a problem coefficient, to which I assigned unit value.
IRmax=1;
Ipar=[0.4 1 1.6]'
IR=[0.02 0.65 0.95]'
ftype=fittype(@(A,B,IRmax,Ipar) IRmax.*(1-exp(Ipar./A).^B),'problem','IRmax','independent','Ipar','dependent','IR')
IRfit=fit(Ipar,IR,ftype,'problem',IRmax,'StartPoint',[1,1])
When I run the script, I obtain the following error message:
Undefined operator '==' for input arguments of type 'cell'.
- Error in strncmp (line 16)
m = all( a(1:n) == b(1:n) );
- Error in fit>iParseOptionalArgs (line 968)
ind = find( strncmp( 'p', varargin(1:2:end), 1 ) );
-Error in fit (line 105)
[useroptions, useroptargs, probparams] = iParseOptionalArgs( varargin{:} );
- Error in IR_calibrate (line 7)
IRfit=fit(Ipar,IR,ftype,'problem',IRmax,'StartPoint',[1,1])
I can't see the bug in the code. Can someone please help?
Thanks.

댓글 수: 1

Satyajeet Sasmal
Satyajeet Sasmal 2015년 8월 19일
편집: Satyajeet Sasmal 2015년 8월 19일
Hi Marco,
Which version of MATLAB are you using? The code runs fine for me in both MATLAB R2015a and R2013a.
And also, please be sure that you have not overshadowed any of the MATLAB built-in functions like "fit" and "fittype".

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

질문:

2015년 8월 17일

편집:

2015년 8월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by