Mercurial > hg > ishara
annotate dsp/wigner.m @ 32:c3b0cd708782
Imported core dsp tools.
author | samer |
---|---|
date | Sun, 20 Jan 2013 13:48:47 +0000 |
parents | |
children |
rev | line source |
---|---|
samer@32 | 1 function wig = wigner(sig,m,l,k,win) |
samer@32 | 2 % Wigner -- Wigner-Ville Distribution. This version |
samer@32 | 3 % operates on an entire signal in a vector. |
samer@32 | 4 % Usage |
samer@32 | 5 % wig = wigner(sig,m,l,k,win) |
samer@32 | 6 % Inputs |
samer@32 | 7 % sig 1-d signal |
samer@32 | 8 % m half window length (must be power of 2) |
samer@32 | 9 % l number of frequencies (ie rows in output) |
samer@32 | 10 % k window step (defaults to 1) |
samer@32 | 11 % win half window of size m+1 |
samer@32 | 12 % Outputs |
samer@32 | 13 % wig complex-valued matrix representing the Wigner-Ville |
samer@32 | 14 % distribution of zero-extended signal with rows corresponding |
samer@32 | 15 % to frequencies and columns corresponding to times. |
samer@32 | 16 % |
samer@32 | 17 % Side Effects |
samer@32 | 18 % Image Plot of the Wigner-Ville distribution |
samer@32 | 19 % |
samer@32 | 20 |
samer@32 | 21 sig = sig(:); |
samer@32 | 22 n = length(sig); |
samer@32 | 23 |
samer@32 | 24 if nargin<4 k = 1; end |
samer@32 | 25 if nargin<3 l = m+1; end |
samer@32 | 26 if nargin<5 win = ones(m+1,1); end |
samer@32 | 27 |
samer@32 | 28 f = [zeros(m,1); sig; zeros(m,1)]; |
samer@32 | 29 wig = zeros(l,floor(n/k)); |
samer@32 | 30 ix = 0:m; |
samer@32 | 31 |
samer@32 | 32 col=1; |
samer@32 | 33 for t=1:k:n, |
samer@32 | 34 tplus = m + t + ix; |
samer@32 | 35 tminus = m + t - ix; |
samer@32 | 36 R = win .* ( f(tplus) .* f(tminus) ); |
samer@32 | 37 x = [ R(1:m); R(m+1:-1:2) ]; |
samer@32 | 38 y = fft(x); |
samer@32 | 39 wig(:,col) = real(y(1:l)); |
samer@32 | 40 col = col+1; |
samer@32 | 41 end |
samer@32 | 42 |