lsqcurvefit error: output argument "s" not assigned during call to replace

2 ビュー (過去 30 日間)
JJ Lamb
JJ Lamb 2021 年 6 月 15 日
編集済み: JJ Lamb 2021 年 6 月 15 日
I use lsqcurvefit for a fair amount of nonlinear curvefitting. I don't think I've tried to use it since I've upgraded to 2020b, but now I'm not sure if I'm making a code error or if something got changed in the update.
I have one call to lsqcurvefit that works, and another that does not and I cannot figure it out. I've tried to code a very simple example to see what's going.
myFun = @(a,xdata) a*xdata; % f(x) = a*x
x = 1:20;
y = 2*x; % simply multiply x by 2
A = lsqcurvefit(myFun,2,x,y); % A should be 2 since I'm fitting some linear data
And then this is the error message that I get:
Output argument "s" (and maybe others) not assigned during call to "replace".
Error in snls (line 269)
msgData = {{replace(msgID,'detailed','basic')}, ...
Error in lsqncommon (line 178)
snls(funfcn,xC,lb,ub,flags.verbosity,options,defaultopt,initVals.F,initVals.J,caller, ...
Error in lsqcurvefit (line 278)
Error in untitled2 (line 4)
A = lsqcurvefit(myFun,2,x,y);
From what I can tell, there's a problem with the call to "replace.m" in the function "snls.m"
I think it has something do with a string being defined using single quotes 'str' vs double quotes "str" before being used in the replace function in the "snls.m" file, but I'm not sure. I don't really know how I could adjust my call to lsqcurvefit to avoid getting this error or what I'm entering incorrectly.
  1 件のコメント
JJ Lamb
JJ Lamb 2021 年 6 月 15 日
編集済み: JJ Lamb 2021 年 6 月 15 日
I don't have a clue what changed, but I restarted MATLAB and it seems to be working? Running the exact same code, but with no error now. Still not totally sure what was going on, so I'll just leave this up in case something else similar happens to someone else.


回答 (0 件)




Community Treasure Hunt

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

Start Hunting!

Translated by