fittype() errors for an M-file function
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!