Switch to unified view

a b/Feature Extraction/extractPSD.m
1
function X=extractPSD(x_train,startS,endS,wStep,wRange)
2
Fs=1;   % sampling frequency (seconds)
3
4
FS=128;
5
6
N=size(x_train,3);
7
sz=floor((endS-(startS+wRange))/wStep)+1;
8
X=zeros(sz*FS,2);
9
cn=0;
10
for i=1:N
11
    
12
    for sig=startS:wStep:endS-wRange
13
        
14
        sW=sig*FS+1;
15
        eW=(sig+wRange)*FS;
16
        
17
        C3Sig=x_train(sW:eW,1,i);
18
        C4Sig=x_train(sW:eW,3,i);
19
        
20
        [pxx3, ~] = pwelch(C3Sig,[],[],[],Fs);
21
        [pxx4, ~] = pwelch(C4Sig,[],[],[],Fs);
22
        
23
        cn=cn+1;
24
        X(cn,1)=sum(pxx3);
25
        X(cn,2)=sum(pxx4);
26
        
27
    end
28
end
29
30
end
31
32