Fitting an equation to a Sine Function with NonLinearModel.fit

I am trying to fit an equation to a set of data that behaves like the sine wave. The data is graphed below:
I already tried using the "cftool" function in matlab but it did not have the equation I need.
I need to use the following equations:
y = a0 + a1*x + a2*sin(a3*x+a4)
y = a1*x + a2*sin(a3*x+a4)
y = a0 + a1*x + a2*sin(a3*x+a4) + a5*sin(a6*x+a7)
Does anyone know how to use "NonLinearModel.fit" in order to fit one of the above functions to the graphed data? The x and y matrices are listed below.
Thanks in advance!
x = [0
90
180
270
360
450
540
630
720
810
900
990
1080
1170
1260
1350
1440];
y = [0
0.00599999999997181
0.00999999999999091
0.00499999999999545
0.0029999999999859
0.0029999999999859
0.00999999999999091
0.0149999999999864
0.0159999999999627
0.0029999999999859
0.00399999999996226
0.00599999999997181
0.00199999999995271
0.0109999999999673
0.0129999999999768
0.00999999999999091
0.00399999999996226];

 Réponse acceptée

Stephan
Stephan le 5 Déc 2019
"...I already tried using the "cftool" function in matlab but it did not have the equation I need...."
Did you notice that you can take adcantage of the custom function in cftool? Have a read here:

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox 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!

Translated by