Calculate mean of an array in time windows.
    7 次查看(过去 30 天)
  
       显示 更早的评论
    
Hi
i have EEG data recorded at 1200hz from 5 channels, for 10 repetitions, and i need to calculate mean of each 1s signal in 10 time windows (each of 100ms) as a features. Is thi the right way to do.? Although the features i'm getting isn't right.
for repetition = 1:size(EEG,3) % loop through repetitions
    featCnt = 1; % feature counter for generic choice of features or channels
    chanCnt = 1;
    for channel = 1:length(channels)
    for window = 1:10
        % calculate mean for current repetition and channel
       features(repetition,featCnt) = mean(EEG(repetition)+(1200/10)*(window-1):(EEG(repetition)+(1200/10)*(window+1)-1));
         featLabels{featCnt} = sprintf('%s_Mean_%i',chanLabels{chanCnt},window);
        featCnt = featCnt + 1; % Count up, for generic choice of feature or channels
    end
    chanCnt = chanCnt + 1;
    end
end
0 个评论
回答(1 个)
  Athul Prakash
    
 2020-1-24
        I'm not sure how you have arranged your data within the matrix 'EEG' - which dimensions correspond to which attributes?
I noticed that in the following line:
features(repetition,featCnt) = mean(EEG(repetition)+(1200/10)*(window-1):(EEG(repetition)+(1200/10)*(window+1)-1));
you are indexing into EEG using just one variable 'repetition'. But you seem to be looping through dimension-3 of EEG with the same variable - this would produce the wrong result.
I would recommend understanding Matlab's indexing thoroughly before you get working on matrix math such as this. Have a look at this doc:
If you need to brush up on or practice working with loops, indexing etc, Maltab OnRamp is a good place to start.
0 个评论
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 EEG/MEG/ECoG 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!