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);
    plot(f, 10*log10(pxx));
    xlabel('Frequency (Hz)'); ylabel('PSD (dB/Hz)');

How do i get the average pwelch of all windows?

  • $\begingroup$ 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). $\endgroup$ – applesoup Feb 23 '19 at 9:50
  • $\begingroup$ Cool! Glad I could help... $\endgroup$ – applesoup Feb 23 '19 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.