fittype() errors for an M-file function
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!