comparison dsp/dftfmap.m @ 32:c3b0cd708782

Imported core dsp tools.
author samer
date Sun, 20 Jan 2013 13:48:47 +0000
parents
children
comparison
equal deleted inserted replaced
31:8cc4f326fc66 32:c3b0cd708782
1 function F=dftfmap(N,Fs)
2 % dftfmap - Frequency map for DFT of real signal
3 %
4 % dftfmap :: N:natural, real ~'sampling rate' -> dmap(dftbins(N)).
5
6 M=dftbins(N);
7 F=dmap(M,@map,@revmap);
8
9 function I=map(X)
10 I=round(N*X/Fs);
11 I(X<0)=-inf;
12 I(X>Fs/2)=inf;
13 end
14
15 function X=revmap(I)
16 I=shiftdim(shiftdim(I),-1);
17 X1=Fs*(2*I-3)/(2*N);
18 X2=Fs*(2*I-1)/(2*N);
19 X1(I<=1)=0;
20 X2(I>=M)=Fs/2;
21 X=cat(1,X1,X2);
22 end
23 end
24