Mercurial > hg > ishara
view dsp/mag_phase_join.m @ 32:c3b0cd708782
Imported core dsp tools.
author | samer |
---|---|
date | Sun, 20 Jan 2013 13:48:47 +0000 |
parents | |
children |
line wrap: on
line source
function o=mag_phase_join(N) % mag_phase_join - get mag and phase spectra and recombine to signal % % mag_phase_join :: N:natural -> arrow( {[[M,L]], [[M,L]]}, {[[N,L]]}, empty) :- M=dftbins(N). % % Version 2 corrects error in V. 1 - the wrong bands were being % doubled up in the power reckoning. This version now guarantees % that sum(magspec(x).^2) = sum(x.^2). bins=1+floor(N/2); last_double=ceil(N/2); singles=1:last_double:bins; o=arr(@mpj); function X=mpj(S,P) S(singles,:)=S(singles,:)*sqrt(2); P(singles,:)=real(P(singles,:)); Z=P.*(S*sqrt(N/2)); X=ifft([Z;conj(Z(last_double:-1:2,:))]); end end