FFT and smoothing of signal

Hi, I have the attached signal (TENS_LOW). I would like to obtained the smoothed FFT of the signal. How can I smooth the spectrum?
Thanks

5 Comments

And what is the problem?
doc fft
I'd like to know how to smooth the spectrum.
Your file has no time vector or sampling frequency.
What is your sampling frequency?
How to smooth the spectrum depends what you want to do with it really. There are plenty of ways to do it, depending how aggressive you want to be. A simple mean filter would do if you just want aggressive smoothing, but not if you want to retain certain information in peaks etc
sampling frequency is 0.0117

Sign in to comment.

 Accepted Answer

Now I understand what you want to do. This is most easily done with the Signal Processing Toolbox sgolayfilt function to create the Savitzky-Golay filtered spectrum.
The Code —
D = load('Isma_gp TENS_LOW.mat');
sig = D.TENS_LOW_42;
sig = sig - mean(sig); % Remove d-c Offset
L = length(sig);
Fs = 1/0.0117; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
FTsig = fft(sig)/L;
Fv = linspace(0, 1, fix(length(FTsig)/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
FTsiga = double(abs(FTsig(Iv))*2); % Truncate, Magnitude, Convert To Double
sgf_sm = sgolayfilt(FTsiga, 5, 501); % Create ‘sgolayfilt’ Filtered FFT
figure(1)
plot(Fv, FTsiga)
hold on
plot(Fv, sgf_sm, '-r', 'LineWidth',2)
hold off
axis([0 1 ylim])
grid
xlabel('Frequency')
ylabel('Amplitude')
legend('Original Spectrum', 'Savitzky-Golay Filtered Spectrum')
Experiment with the sgolayfilt parameters to get the result you want.

12 Comments

Could you comment on why there is the *2 in this line?
FTsiga = double(abs(FTsig(Iv))*2);
Thank you! Kind regards, Maria-Daphne
The fft function creates a full (two-sided) Fourier transform, dividing the energy between the negative frequencies and the positive frequencies (most easily realised by using the fftshift function and creating an appropriate frequency vector that extends from the negative Nyquist frequency to the positive Nyquist frequency). Displaying the one-sided Fourier transform (as I do here) requires that the amplitudes be doubled in order to approximate the original signal amplitudes at those frequencies. (This is simply a convention, not a requirement.)
.
Thank you @Star Strider !!!
@Star Strider, thank you very much for this example and explanation. It helped me a lot!
@Iuri Baldaconi — My pleasure!
Thank you for the vote!
If I want to use 'sgolayfilt' for smoothing the frequency response and then transform the smoothed frequency response to time domain, what should I do?
@NASRIN AKTER — Do essentially what I did here.
@Star Strider, sorry I didn't get you. If I take the absolute value of frequency response for 'sgolayfilt' and then do 'ifft' after smoothing, would that be correct?
@NASRIN AKTER — No.
This implementation of sgolayfilt smooths the absolute value of the fft result. To perform an ifft on the smoothed values, it would be necessary to filter the real and imaginary parts separately, and then combine them first. However I doubt that would be successful. Instead, take the ifft of whatever result you want, and filter that, or better yet, filter the signal before taking the fft.
Hi @Star Strider, I think this is a brilliant solution to smooth the fft for which there are not so much other oprions to smooth it, such as for the PSD where we can use pwelch and a windowing. Are there any reference (literature) where this method of smoothing is used?
@SYML2nd — Not to my knowledge, although I did not do a literature search. My approach here is essentially empirical.

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!