Debugging a code for fitting an anonymous function
Show older comments
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 Comment
Satyajeet Sasmal
on 19 Aug 2015
Edited: Satyajeet Sasmal
on 19 Aug 2015
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".
Answers (0)
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!