How do I window my pwelch function on matlab. I only get an average of the first window

I am implementing a signal processing algorithm to determine tremor and non tremor activity in a signal. The tremors of interest are in the range of 4-8Hz and I need to find the max value for each window but i am only getting one plot and when i use a for loop with a window the same pwelch signal outputs like 6 times. Here is my code:

wind = 2;
ws = wind * samp_freq;
trem_feat = (filt_trem);

for  i = 1:ws:L-ws
window = i : i+ws;
[pxx, f] = pwelch(trem_feat ,500 ,300 ,500 ,samp_freq);
figure;
plot(f, 10*log10(pxx));
title('PSD');
xlabel('Frequency (Hz)'); ylabel('PSD (dB/Hz)');
end


How do i get the average pwelch of all windows?

• Hi Jot, and welcome to DSP.SE. You compute the Welch estimate of the data in trem_feat in the loop but trem_feat does not change. I did not test it, but I think you should change pwelch(trem_feat,500,300,500,samp_freq) to pwelch(trem_feat(window),500,300,500,samp_freq). – applesoup Feb 23 '19 at 9:50
• Cool! Glad I could help... – applesoup Feb 23 '19 at 18:42