FWHM and FFT algorithm
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a question on FFT algorithm: I have created some DHO functions (Damped Harmonic Oscillator) of the form:
y=exp(-G*pi*t).*sin(2*pi*freq*t);
where G is the attenuation factor of the exponential modulator of y function. I tried to do an FFT algorithm of y and successively to fit using a nonlinearleastsquares algorithm the Fourier Transform of the DHO function using some parameters. The fit operation is very good but I don't understand why the fit result obtained from FFT is 0.55 when the G value inserted in y is 0.6.
Has someone seen this underestimation of FWHM of the fourier transform using FFT from the real value G=0.6 inserted in y?
Réponses (1)
Prateekshya
le 17 Oct 2024
Hello Luca,
The discrepancy you're observing between the actual damping factor G and the estimated value from the FFT could be due to several factors related to the nature of the FFT and the properties of the damped harmonic oscillator (DHO) function. Here are some potential reasons and considerations:
Resolution of the FFT:
The frequency resolution of an FFT is determined by the sampling rate and the length of the signal. If the resolution is not fine enough, it can lead to inaccuracies in estimating parameters like the damping factor. Ensure that your sampling rate and the duration of the signal are sufficient to capture the details of the damped oscillation. A longer signal or higher sampling rate can improve frequency resolution.
Windowing Effects:
When performing an FFT, the implicit assumption is that the signal is periodic within the window. If your signal is not windowed properly, spectral leakage can occur, affecting the estimation of parameters. Apply a window function (e.g., Hann, Hamming) to your signal before performing the FFT to reduce spectral leakage.
Fitting Procedure:
The fitting process itself might introduce some discrepancies if the model or the fitting algorithm isn't perfectly aligned with the data characteristics. Ensure that the initial parameter guesses for the nonlinear least squares fitting are close to the expected values. Poor initial guesses can lead to suboptimal fitting results. Verify that the model used for fitting accurately represents the Fourier transform of the DHO function, taking into account all relevant parameters and their relationships.
Numerical Precision:
Numerical precision and computational errors can sometimes lead to small discrepancies, especially when dealing with floating-point arithmetic. Ensure that your computations are performed with adequate precision. MATLAB typically uses double-precision floating-point arithmetic, which should suffice for most applications.
Here is a basic example of how you might set up the FFT and fitting process in MATLAB:
% Parameters
G = 0.6; % Damping factor
freq = 5; % Frequency in Hz
t = 0:0.001:10; % Time vector
% Damped harmonic oscillator
y = exp(-G * pi * t) .* sin(2 * pi * freq * t);
% Perform FFT
Y = fft(y);
n = length(t);
f = (0:n-1) * (1/(max(t)-min(t)));
% Plot the magnitude of the FFT
figure;
plot(f, abs(Y));
xlabel('Frequency (Hz)');
ylabel('Magnitude');
title('FFT of Damped Harmonic Oscillator');
% Fit the FFT result
% Define the model for fitting
model = @(b, f) b(1) ./ sqrt((f - b(2)).^2 + (b(3)/2).^2);
% Initial guess for parameters [amplitude, frequency, damping factor]
initialGuess = [max(abs(Y)), freq, G];
% Perform nonlinear least squares fitting
fitResult = lsqcurvefit(model, initialGuess, f, abs(Y));
% Display the fitted damping factor
fittedG = fitResult(3);
fprintf('Fitted damping factor: %.2f\n', fittedG);
I hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!