fittype() errors for an M-file function

조회 수: 3 (최근 30일)
Val
Val 2011년 12월 28일
I am trying to fit a data set using a custom M-file function. The function does well when called explicitly but gives me an error message when a part of a fittype() function. I am not sure what even can be wrong here. Here is the piece of the code:
yFit = Kin2UpDn(x,k1,k2,k3,k4,Btotal); % this works fine
BObs = fittype('Kin2UpDn(x,k1,k2,k3,k4,Btotal)'); % this is the next line; fails with the error message below
opt = fitoptions('Method','NonlinearLeastSquares','Algorithm','Levenberg-Marquardt','MaxIter',10,'Robust','Bisquare','Startpoint',[k1; k2; k3; k4; Btotal]); % this is the next line
Error: ??? Error using ==> fittype.fittype>fittype.fittype at 477 Expression Kin2UpDn(x,k1,k2,k3,k4,Btotal) is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated: Error in fittype expression ==> Kin2UpDn(x,k1,k2,k3,k4,Btotal) ??? Index exceeds matrix dimensions.
x is a vector; k1,k2,k3,k4,Btotal are scalars.
Many thanks for any help

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by