How to fit a custom function using nlinfit?
Afficher commentaires plus anciens
I have written a function 'fun' in a separate .m file that I would like to fit to some xy data, using a parameter 'A' as a fitting parameter. However, since the function depends on the input of xdata and the parameter A to run, I am no sure how to fit it using nlinfit (or similar). When I enter the following, matlab returns an error:
nlinfit(xdata,ydata,fun,A)
Error in fun(line 13)
Not enough input arguments.
So apparently, the xdata and A do not end up like this:
fun(xdata,A)
Does anybody know how to fit a function that was not defined using a function handle?
Thanks in advance!
2 commentaires
Image Analyst
le 11 Déc 2017
Please attach your data and tell us the model you wish to fit to it. In the meantime, I've attached 3 demos that perhaps can be adapted to your situation.
Steven C
le 12 Déc 2017
Réponses (0)
Catégories
En savoir plus sur Common Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!