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

조회 수: 1 (최근 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)
lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,optimgetFlag,caller,...
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개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by