Reply by abdulhaseeb86 June 10, 20102010-06-10
I want to calculate relative power of two signals what is the correct matlab code to do that. Actually one signal is the filtered version of the other, because i want to find the power contained in the specific band of frequencies.
The code I am trying to use is this:

x = wavread('sc4012_subj1_Pz-Oz.wav');

%Filter Specs
n;
Wn=[8 12]/50;
[b,a] = butter(n,Wn,'bandpass');

x_fil = filter(b,a,x);

%%%% Welch's Periodogram
%[Pxx,f] = pwelch(x,window,noverlap,nfft,fs)
[X,f] = pwelch(x,200,100,[],100); % EEG Power spectrum
[X_fil,fa] = pwelch(x_fil,200,100,[],100); % alpha power spectrum

%%%% IFFT

X_FIL = ifft(X-fil);
X = ifft(X);

%%%% Cyclic Shift of IFFT results
Nhalfa = floor(length(X_FIL)/2);
SecondHalfa = X_FIL(1:Nhalfa+1);
FirstHalfa = X_FIL(Nhalfa+2:length(X_FIL));

afixed_cyc = [FirstHalfa;SecondHalfa]; % EEG cyclic

Nhalfp = floor(length(X)/2);
SecondHalfp = X(1:Nhalfp+1);
FirstHalfp = X(Nhalfp+2:length(X));

pfixed_cyc = [FirstHalfp;SecondHalfp]; % Alpha cyclic

%%%% Finding Alpha Relative
alphaRelative = afixed_cyc./pfixed_cyc;