How can I fit data to a sine curve?
203 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Given a set of data points, how can I find the curve of best fit if I know that this will be a sine curve and nothing else?
0 commentaires
Réponses (2)
John D'Errico
le 28 Sep 2019
I'll guess the model you want is as below, but use the curve fitting toolbox.
Your model might be defined as:
ft = fittype('sin((x - shift)/xscale)*yscale','coefficients',{'shift','xscale','yscale'})
ft =
General model:
ft(shift,xscale,yscale,x) = sin((x - shift)/xscale)*yscale
Now just call fit to fit the model to your data.
mdl = fit(X,Y,ft,'startpoint',[shiftguess,xscaleguess,yscaleguess]);
Other toolboxes have similar capability, but not quite as easy to use as the CFTB. (Stats TB, optimization TB)
Star Strider
le 28 Sep 2019
It just uses core MATLAB functions. No toolboxes needed at all.
0 commentaires
Voir également
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox 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!