Script for curve fitting
31 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, being very newish to Matlab I am trying to solve a simple problem to begin with, and advance from there. I have 2 sets if data (named x and y in workspace). When I use curve fitting tool to fit the data, it works fine, but if I use the script below in .m file, I get error saying more input arguments are needed to run.
ft = fittype ('poly4'); [xdata, ydata] = prepareCurveData(x,y); c = fit(xdata,ydata,ft);
I have tried the fit from curve fitting toolbox and using generate code function and I get the same error. What am I missing here?
Any help is appreciated.
0 commentaires
Réponses (1)
Shashank Prasanna
le 19 Mar 2013
'Generate code' usually returns a function and not a scrip. Is it possible that you are not calling the function with the right arguments?
Could you paste the exact error message from the command line?
Also, could you run the following and see if it works?
>> x = rand(10,1);
>> y = rand(10,1);
>> ft = fittype ('poly4'); [xdata, ydata] = prepareCurveData(x,y); c = fit(xdata,ydata,ft);
4 commentaires
Shashank Prasanna
le 19 Mar 2013
Modifié(e) : Shashank Prasanna
le 19 Mar 2013
Just to add to that, you can't just execute the generated code. You will need to call it as showed above, either from the command line or from another script. hth.
Voir également
Catégories
En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!