Remove ripples from frequency domain
조회 수: 17 (최근 30일)
이전 댓글 표시
I am trying to get the PSD of certain signal ( lift coefficient which changes with time and periodic).
when I draw the semilogy of the result, I find ripples around the peaks like the photo attached.
How can I remove the ripples?
https://ibb.co/5jkrHvZ
댓글 수: 5
Image Analyst
2022년 2월 2일
@yusuf albadry, well, not really. You basically said you need to remove the peaks because you need to remove the peaks. But you didn't really say why you need to remove the peaks ("to provide smooth representation"). Sure, you can use a hamming window, or maybe subtract the mean from the signal prior to the fft, and the lobes/peaks will be lower. By the way, the peaks could be caused by your signal having a non-zero mean. So it's offset/lifted above zero, thus it's like being multiplied by a rect function. And as you know multiplication by a rect give a convolution with a sinc function in the frequency domain - hence the peaks. Multiplying by a Hamming window rounds off the outer edges of the signal making the rect not as sharp, thus making the lobes smaller. But what will getting rid of peaks do for you, other than make the spectrum look smoother? What would you now be able to do that you couldn't before?
Paul
2022년 2월 3일
Isn't the signal having a non-zero mean similar to a zero-mean signal with a rectwin added to it, and therefore the primary effect of the non-zero mean would only be lifting the spectrum at low frequency (like shown below in @William Rose's answer)? Why would a non-zero mean be like multiplication by a rectwin?
답변 (2개)
William Rose
2022년 2월 2일
Yes, try a hann() window, or another window sum as hamming(). There is a good chace that there will still be downward spikes in the power spectrum of the windowed signal, but the spikes will be at slightly different frequencies. You will have to experiment.
Perhaps you want to smooth the spectrum because you want to identify peaks automatically or in near-real time. If that is the case, then the concern of @Image Analyst, which is that the inverse transform of the smoothed spectrum might not be like the original signal, is not really a concern. I understand that the downward spikes can cause you to identify too many peaks. Matlab's findpeaks() has a variety of optional arguments that are quite useful. For example, 'MinPeakDistance' specifies the minimum horizontal distance between identified peaks. Try movmax(), as @Image Analyst suggested, with an odd k to get a centered estimate. You will have to experiment to find the width, k, that gives satisfactory results.
댓글 수: 0
William Rose
2022년 2월 2일
That is a very interesting and good point by @Image Analyst about the non-zero mean. See below for examples of spectra with and without the mean removed, and with and without a Hamming window. By suppressing sidelobes, the Hamming window makes peaks easier to distinguish by eye or automatically.
fs=2; %samping rate
t=(0:199)/fs; %time vector, 100 seconds long
f1=0.325;f2=0.665;f3=.905; %frequencies in the signal
%next: generate the time-domain signal
x=1+cos(2*pi*f1*t)+.1*sin(2*pi*f2*t)+.05*cos(2*pi*f3*t);
%next: compute power spectrum
[pxx,f]=periodogram(x,rectwin(length(x)),1000,fs);
subplot(411), semilogy(f,pxx);
ylabel('Magnitude'); grid on; ylim([1e-5 1e2])
title('Rectangular window, non-zero mean');
[pxx,f]=periodogram(x,hamming(length(x)),1000,fs);
subplot(412), semilogy(f,pxx);
ylabel('Magnitude'); grid on; ylim([1e-5 1e2])
title('Hamming window, non-zero mean');
[pxx,f]=periodogram(x-mean(x),rectwin(length(x)),1000,fs);
subplot(413), semilogy(f,pxx);
ylabel('Magnitude'); grid on; ylim([1e-5 1e2])
title('Rectangular window, mean removed');
[pxx,f]=periodogram(x-mean(x),hamming(length(x)),1000,fs);
subplot(414), semilogy(f,pxx);
xlabel('Frequency (Hz)'); ylabel('Magnitude'); grid on; ylim([1e-5 1e2])
title('Hamming window, mean removed');
Try.
댓글 수: 1
William Rose
2022년 2월 3일
The ony way one can reproduce the downward spikes in the spectrum is by oversampling in the frequency domain. By oversampling I mean I requested that periodogram return a spectrum at 1000 frequencies [periodogram(x,window,1000)], even though the original signal only had N=200 points. If I had just used nfft=N=200, which is a good choice, then you don't see the spikes. See below:
fs=2; %samping rate
t=(0:199)/fs; %time vector, 100 seconds long
N=length(t); %number of points in the signal
f1=0.325;f2=0.665;f3=.905; %frequencies in the signal
%next: generate the time-domain signal
x=1+cos(2*pi*f1*t)+.1*sin(2*pi*f2*t)+.05*cos(2*pi*f3*t);
%next: compute power spectrum
[pxx,f]=periodogram(x-mean(x),rectwin(N),N,fs);
subplot(211), semilogy(f,pxx);
ylabel('Magnitude'); grid on; ylim([1e-5 1e2])
title('Rectangular window, mean removed');
[pxx,f]=periodogram(x-mean(x),hamming(N),N,fs);
subplot(212), semilogy(f,pxx);
xlabel('Frequency (Hz)'); ylabel('Magnitude'); grid on; ylim([1e-5 1e2])
title('Hamming window, mean removed');
참고 항목
카테고리
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!