Fittype TestAnonymousFunction Argument Error

Can someone please explain why I keep getting this error?
Error using fittype>iTestAnonymousFunctionArgumentOrder (line 811) The coefficients must come before the problem parameters.
I have my function as:
fun=@(F,PS,fp,fis,x)...
longobjfun(x,F,PS,fp,fis,A);
ft = fittype(...
fun, ...
'problem',{'A'},...
'coeff', {'F','PS','fp','fis'});
I know that for fittype, the anonymous function has to have a form of:
fun = @(fitparameters, problemparameters, independent) expression;
It stated that problemparameters can be optional. How do I remove this? I'm not sure what to do with this.

답변 (1개)

Chandani Madnani
Chandani Madnani 2017년 10월 6일

0 개 추천

Modify the code as shown below to pass the Problem parameter and see if it works:
fun=@(F,PS,fp,fis,A,x)... longobjfun(x,F,PS,fp,fis,A); ft = fittype(... fun, ... 'problem',{'A'},... 'coeff', {'F','PS','fp','fis'});

댓글 수: 4

Arbol
Arbol 2017년 10월 6일
I have tried and rearrange like yours, I get this error: Error using fittype/testCustomModelEvaluation (line 12) Expression model_2cxm_cfit(x,fp,PS,vp,ve,A) is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated: Error while trying to evaluate FITTYPE function :
Matrix dimensions must agree.
Arbol
Arbol 2017년 10월 6일
Also, on one note, can A be a vector? the problem value?
Arbol
Arbol 2017년 10월 7일
편집: Arbol 2017년 10월 7일
I have got this fixed. But I have no idea how it was fixed. It could due to that i didnt clear the fittype, so it still keep the old fittype and carry over to the next run.
My fix is as followed (for future reference if someone look at this):
fun=@(F,PS,fp,fis,x)...
longobjfun(F,PS,fp,fis,A,x);
ft = fittype(fun, ...
'independent',{'x'},...
'coeff', {'F','PS','fp','fis'});

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

태그

질문:

2017년 10월 4일

댓글:

2017년 10월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by