Add constants in nlinfit
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi there,
is there a way that I provide nlinfit with some constants that are taken into account when solving a function?
So, for example, I use this code for nlinfit:
[xfit,resnorm, Jacob, CovB, MSE] = nlinfit( handles.timecorr,handles.datacorr',@DiffEqSolver300, B );
I would like to give another set of parameters to the function DiffEqSolver300 that should not be fitted, but they depend on calculations that happens before I call the nlinfit function. Is this somehow possible?
Just a simple example. Let's assume the function that should be fitted is
y = A*x + B;
Depending on some input parameters, A could be 1 or 10 or 100 and B is a fitting parameter. How can I tell the function which value A should have?
댓글 수: 0
채택된 답변
Star Strider
2017년 12월 21일
편집: Star Strider
2017년 12월 21일
Writing your own objective function, you simply need to pass ‘A’ as a parameter.
Example —
objfcn = @(B,x,A) A*x + B;
then call it in nlinfit as:
beta = nlinfit(x, y, @(B,x) objfcn(B,x,A), ... );
so that ‘objfcn’ accepts ‘A’ as a parameter, and the function works with nlinfit as it would if no additional parameters were passed.
댓글 수: 6
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!