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