How to fit a custom function using nlinfit?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Image Analyst
am 11 Dez. 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.
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!