Fitting an equation to a Sine Function with NonLinearModel.fit

조회 수: 5 (최근 30일)
Wesley Brown
Wesley Brown 2019년 12월 4일
댓글: Wesley Brown 2019년 12월 7일
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