i am using the lsqcurvefit function in my coding and there is errorfitted that reflecting the local fit different. Let say the errorfitted value is 28.2524. May I know what is the errorfitted value unit perhaps %?

 채택된 답변

William Rose
William Rose 2021년 3월 29일

0 개 추천

The Matlb help for lsqcurvefit() does not show any output variable with the name errorfitted. The outputs available from lsqcurvefit() are shown under Syntax, below. Which of these output variables corresponds to the quantity which you are calling errorfitted?
My guess is that you are referring to resnorm or to residual.
  • resnorm is a scalar. It equals the sum of the squared differences between ydata and f(xdata). Therefore the units for resnorm are squared (y-units).
  • residual is a vector or array, if ydata is a vector or array. It equals the differences between ydata and f(xdata). Therefore the units for residual are y-units.
Syntax
x = lsqcurvefit(fun,x0,xdata,ydata)
x = lsqcurvefit(fun,x0,xdata,ydata,lb,ub)
x = lsqcurvefit(fun,x0,xdata,ydata,lb,ub,options)
x = lsqcurvefit(problem)
[x,resnorm] = lsqcurvefit(___)
[x,resnorm,residual,exitflag,output] = lsqcurvefit(___)
[x,resnorm,residual,exitflag,output,lambda,jacobian] = lsqcurvefit(___)

댓글 수: 3

Thanks for the quick response. However I am referring to attach figure syntax:
The value of the errorfitted at 28.2524 is in % or else?
p/s: this snip is from the matlab documentation. search: errorfitted.
When lsqcurvefit() is called as
[xfitted,errorfitted] = lsqcurvefit(fitfcn,p0,xdata,ydata,lb,ub)
then the arguments correspond, in order, to the arguments in the manual for that function, even though the names may be diferent. This is an important idea that applies whenever you are calling funcitons or readin other people's code. The manual page here shows that (when we combine the function call examples with 2 args on the left and 6 args on the right):
[x,resnorm] = lsqcurvefit(fun,x0,xdata,ydata,lb,ub)
Therefore errorfitted is the variable name used above to receive the resnorm output - as I guessed in my initial answer. Therefore the units for errofitted are the units for resnorm: squared (y-units). Therefore you may compute the root mean square error (average error per point):
RMSerr=sqrt(errorfitted/N);
where N=number of elements in ydata(), and RMSerror has units of y-units.
Ok understand. Thanks!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Nonlinear Least Squares (Curve Fitting)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by