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
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 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!