Mercurial > hg > ishara
diff dsp/mag_phase_split.m @ 32:c3b0cd708782
Imported core dsp tools.
author | samer |
---|---|
date | Sun, 20 Jan 2013 13:48:47 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dsp/mag_phase_split.m Sun Jan 20 13:48:47 2013 +0000 @@ -0,0 +1,21 @@ +function o=mag_phase_split(N) +% mag_phase_split - arrow to get FFT and do mag/phase split +% +% mag_phase_split :: +% N:natural ~'frame size' +% -> arrow( {[[N,L]]}, {[[M,L]], [[M,L]]},empty) :- M=dftbins(N). + + bins=1+floor(N/2); + singles=1:ceil(N/2):bins; + o=arr(@mps); + + function [S,P]=mps(X) + Y=fft(X,N); + Z=Y(1:bins,:); + M=abs(Z); + P=Z./M; % get complex phases of components. + S=M*sqrt(2/N); % sqrt of double of total power per band + S(singles,:)=S(singles,:)/sqrt(2); % undo double counting of singletons + end +end +