Can I pass fitobject as a variable to a function

조회 수: 2 (최근 30일)
Vinay Killamsetty
Vinay Killamsetty 2019년 11월 18일
댓글: Vinay Killamsetty 2020년 4월 12일
I have curve fit my data using the fit command as given below
[cfit,gof,output] = fit(x,y,fitType)
Now my fitobject is in cfit.
Can I pass this fit object (cfit) as a variable to a function for using the lsqnonlin optimization function
X=___;
Y=___;
[cfit,gof,output] = fit(x,y,fitType)
P0=[ ];%Initial estimation
a=__;%variable
b=__;%variable
lb=[_,...,_];%Lower bound
ub=[_,...,_];%Upper bound
[Widths,resnorm,res,eflag,output1] = lsqnonlin(@(P) function(P,a,b,cfit), P0, lb, ub,options);
%%Function definition
[ ]=function(r,a,b,cfit)
{
fit_result=cfit(r); %for finding the values using fitobject
}
end
Please suggest me know if there is any possiblity for doing this

채택된 답변

Kavya Vuriti
Kavya Vuriti 2020년 1월 17일
Hi,
It is possible to pass cfit object directly to lsqnonlin function.
[Widths,resnorm,res,eflag,output1] = lsqnonlin(cfit, P0, lb, ub,options);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by