Fitting an equation to a Sine Function with NonLinearModel.fit

9 次查看(过去 30 天)
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];

采纳的回答

Stephan
Stephan 2019-12-5
"...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:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by