MATLAB Answers

Fittype TestAnonymousFunction Argument Error

1 view (last 30 days)
Arbol on 4 Oct 2017
Commented: Arbol on 7 Oct 2017
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:
ft = fittype(...
fun, ...
'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.


Sign in to comment.

Answers (1)

Chandani Madnani
Chandani Madnani on 6 Oct 2017
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'});


Show 1 older comment
Arbol on 6 Oct 2017
Also, on one note, can A be a vector? the problem value?
Arbol on 7 Oct 2017
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.
Arbol on 7 Oct 2017
My fix is as followed (for future reference if someone look at this):
ft = fittype(fun, ...
'coeff', {'F','PS','fp','fis'});

Sign in to comment.

Sign in to answer this question.