specifying frequencies in pwelch not working

7 次查看(过去 30 天)
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?

回答(1 个)

Chunru
Chunru 2022-7-29
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');

类别

Help CenterFile Exchange 中查找有关 EEG/MEG/ECoG 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by