Fourier series curve fitting amplitude
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello all,
A quick question regarding fourier curve fitting.
I am using the following:
f=fit(x, y, 'fourier1');
formula(f);
x{i} = x;
y{i} = y;
predicted_y{i} = f(x);
coefficients = coeffvalues(f)
Fit_Amplitude(i) = (coefficients(1,2)^2 + coefficients(1,3)^2)^0.5;
Fit_Wavelength(i) = (2*pi)/coefficients(1,4);
Fit_Wavenumber(i) = coefficients(1,4);
Where fourier1 is f(x) = a0 + a1*cos(x*w) + b1*sin(x*w)
I am using fourier1 but I found that it is not accurate enough, I want to switch to fourier3, the equation will be:
f(x) = a0 + a1*cos(x*w) + b1*sin(x*w) + a2*cos(2*x*w) + b2*sin(2*x*w) + a3*cos(3*x*w) + b3*sin(3*x*w)
Any idea on how to find Amplitude and wavelength through fourier3?
Thank you!
댓글 수: 0
답변 (1개)
Aditya Srikar
2023년 5월 25일
After fitting the data using `fourier3` function in MATLAB, you can use the `coeffvalues` function to extract the Fourier series coefficients, then calculate the amplitude using the first 3 terms of the Fourier series. For calculating the wavelength and wavenumber, use the third term of the Fourier series with the formulas `wavelength = 2*pi/k` and `wavenumber = k`, where `k` is the coefficient for the third harmonic.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Estimation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!