specifying frequencies in pwelch not working

5 views (last 30 days)
Karen Konkoly
Karen Konkoly on 28 Jul 2022
Commented: Chunru on 30 Jul 2022
Last year, I could input the following into pwelch and it would give me a nice output with the mean alpha power in that piece of data
data = EEG.data; %assume this is 1 row of my EEG data of interest
analysisWinSize = 1000; % in data points
Overlap = 500; % in data points. overlap of windows.
FreqOfInterest = 8 : .5 : 12.5;
sr = 1000; %Sampling rate in Hz
freqOverTime = pwelch(data, analysisWinSize, Overlap, FreqOfInterest, sr);
windows.AlphaPowerF3(i) = mean(freqOverTime,'all');
I But now when I try to run it, it first gives the error,
"Error using pwelch (line 503)
pwelch: arg 3 (overlap) must be real from 0 to 0.950000"
If I change the overlap to "[]" (the default is 50% anyways), then I get the error:
Error using pwelch (line 511)
pwelch: arg 4 (Nfft) must be integer >=0
And I can't figure out how to change it. I don't want it to be an integer or Nfft, it is supposed to be an array that specifies the frequencies I want to do the analysis on. The documentation made it seem like the function would interpret the input differently depending on whether it was an integer or array, but I can't figure out a way around this error. Did the pwelch function change? Can anyone help?

Answers (1)

Chunru
Chunru on 29 Jul 2022
No problem for on-line matlab.
data = randn(20000,1); %assume this is 1 row of my EEG data of interest
analysisWinSize = 1000; % in data points
Overlap = 500; % in data points. overlap of windows.
FreqOfInterest = 8 : .5 : 12.5;
sr = 1000; %Sampling rate in Hz
freqOverTime = pwelch(data, analysisWinSize, Overlap, FreqOfInterest, sr);
plot(FreqOfInterest, freqOverTime)
%windows.AlphaPowerF3(i) = mean(freqOverTime,'all');
  2 Comments
Karen Konkoly
Karen Konkoly on 29 Jul 2022
I just tried updating my matlab but that didn't work...

Sign in to comment.

Categories

Find more on EEG/MEG/ECoG in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!