Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[5f391e]: gabor / zak.m Maximize Restore History

Download this file

zak.m    66 lines (53 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function c=zak(f,a);
%ZAK Zak transform
% Usage: c=zak(f,a);
%
% ZAK(f,a) computes the Zak transform of f with parameter _a.
% The coefficients are arranged in an _a x _L/a matrix, where _L is the
% length of f.
%
% If f is a matrix, then the transformation is applied to each column.
% This is then indexed by the third dimension of the output.
%
%
% Assume that c=ZAK(f,a), where f is a column vector of length L and
% N=L/a. Then the following holds for $m=0,...,a-1$ and $n=0,...,N-1$
%
%M N-1
%M c(m+1,n+1)=1/sqrt(N)*sum f(m-k*a+1)*exp(2*pi*i*n*k/N)
%M k=0
%F \begin{eqnarray*}
%F c(m+1,n+1) & = & \frac{1}{\sqrt{N}}\sum_{k=0}^{N-1}f(m-ka+1)e^{2\pi ink/M}
%F \end{eqnarray*}
%
% See also: izak
%
% References: ja94-4 bohl97-1
% AUTHOR : Peter Soendergaard
% TESTING: TEST_ZAK
% REFERENCE: REF_ZAK
error(nargchk(2,2,nargin));
if (prod(size(a))~=1 || ~isnumeric(a))
error([callfun,': a must be a scalar']);
end;
if rem(a,1)~=0
error([callfun,': a must be an integer']);
end;
if size(f,2)>1 && size(f,1)==1
% f was a row vector.
f=f(:);
end;
L=size(f,1);
W=size(f,2);
N=L/a;
if rem(N,1)~=0
error('The parameter for ZAK must divide the length of the signal.');
end;
c=zeros(a,N,W);
for ii=1:W
% Compute it, it can be done in one line!
% We use a normalized DFT, as this gives the correct normalization
% of the Zak transform.
c(:,:,ii)=dft(reshape(f(:,ii),a,N),[],2);
end;
%OLDFORMAT