MATLAB: Setting pwelch frequency resolution

MATLABnfftpwelchtime series

Hi All, I have a time series recorded at 100Hz for which I want to use pwelch (60 sec signal). My prob is that I want to obtain the results with a specific resolution of 0.01Hz and I am struggling to set up the right inputs for the windows, nfft and overlap to achieve that. Any ideas how to do that?
Cheers
Eduardo

Best Answer

Refer to the documentation of “pwelch” function for the calculation of different parameters to be used to achieve the desired frequency resolution. If you want to learn more about how the “pwelch” function is used in a practical application, refer this example here.
The following code snippet will help you in using the “pwelch” function in your application.
% Reset the random number generator for reproducible results.
rng default
fs = 100; % Assuming the sampling frequency is 100 Hz
t = 0:1/fs:60-1/fs; % Assuming that the signal is of 60 Seconds length
x = cos(2*pi*0.01*t) + randn(size(t)); % Create a test signal in which some randomized AWGN noise
% is added to a sinusoidal signal of 0.01 Hz frequency
% Use Welch's power spectral density estimation function to estimate the PSD.
% Calculation of the input parameters for "pwelch" function to get the required frequency resolution
% Resolution Required = 0.01 Hz
resolutonReqd = 0.01;
% Calculate number of FFT points (NFFT) required for the required resolution
% fs/NFFT = resolutionReqd
NFFT = fs / resolutonReqd;
% Set window size for averaging to 200
window = 200; % This makes number of FFT averages to 6000 samples/ 200 = 30
% Set overlap to 0
overlap = 0;
% Now use pwelch with above parameters.
[pxx,f] = pwelch(x,window,overlap,NFFT,fs);
% Now plot the PSD
plot(f,10*log10(pxx))
xlabel('Frequency (Hz)')
ylabel('PSD (dB/Hz)')
Related Question