Sine curve fit to data with an unknown dc offset

조회 수: 15 (최근 30일)
Jerry Yeung
Jerry Yeung 2019년 7월 10일
댓글: Jerry Yeung 2019년 7월 11일
Hi. Apologies if this has been answered before, but I'd like to know if there's any way of fitting a sine curve to a sinusoidal function with unknown frequency and unknown DC offset? The function I'm trying to fit to is a standing wave and is most likely sinusoidal, but is less than half a period long.
Thanks in advance for the help.

채택된 답변

John D'Errico
John D'Errico 2019년 7월 10일
Of course it is possible. Use the curve fitting toolbox.
ft = fittype('a + b*sin((x - c)/d)','indep','x');
mdl = fit(X(:),Y(:),ft,'startpoint',[1, 0.001, 1200, 1000])
I just picked off some very rough starting values from the plot.
Here, a is the DC offset. b is the amplitude of the wave, c is the shift in X, d/(2*pi) is the length of the period. You can transform that to give you frequency.
  댓글 수: 1
Jerry Yeung
Jerry Yeung 2019년 7월 11일
Ah, so that's how you use the fittype function. Thanks for the help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by