fittype() errors for an M-file function

3 vues (au cours des 30 derniers jours)
Val
Val le 28 Déc 2011
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

Réponses (0)

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by