function wavelet_coefs = dwt(data,H,level) % ======================================= % function wavelet_coefs = dwt(data,H,level) calculates the % DWT of periodized data by using filter H. % The depth of the transformation is 'level' % ============= STA 293 ================= n = length(H); N = length(data); if nargin==2, level = round(log10(N)/log10(2)); end; C = data; D = []; G = fliplr(H); G(1:2:n) = -G(1:2:n); % Quadrature Mirror for j = 1:level % Mallat's algorithm N = length(C); C = [C C]; % Make periodic d = filter(G, 1, C); % Convolve d =d(2:2:N); % Downsample D = [d,D]; % Concatenate C = filter(H, 1, C); % Convolve C =C(2:2:N); % Downsample end; % wavelet_coefs = [C,D]; % DWT %========================================================================