nonlinear curve fitting: how to add an extra data vector?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi, I know how to fit a curve to the ' ydata ' vector, e.g.:
opt = fitoptions('Method','NonlinearLeastSquares',...
'Startpoint',[1,0.2]);
fun = fittype('p1*cos(x)+p2*sin(x)','options',opt);
[fitobject,gof,output] = fit(time',ydata,fun)
However, I would like to include an additional data vector [same size as time and ydata(time) ] as a non-free time varying parameter [ pdata(time) ] to the function, so that we have something along this form:
fun = fittype('pdata*(p1*cos(x)+p2*sin(x))','options',opt);
Does anyone know how to implement this?
댓글 수: 0
답변 (1개)
Matt J
2014년 9월 24일
편집: Matt J
2014년 9월 24일
You can specify the model as an anonymous function and pass parameters to that in the usual way and/or you could use the 'problem' input option to fittype/fit, see
댓글 수: 2
Matt J
2014년 9월 25일
fun = fittype( @(p1,p2,x) pdata.*(p1.*cos(x)+p2.*sin(x)),'problem','pdata');
[fitobject,gof,output] = fit(time',y,fun,'problem',pdata)
참고 항목
카테고리
Help Center 및 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!