function wavelet_stem(wname) % Makes 'stem plots' of level-4 wavelets and scaling vectors for series of % length 2^4.(assuming periodic extension if necessary) % Example call: % wavelet_stem('haar') % Stem plot of Haar wavelets and scaling vectors levmax = 4; N = 2^levmax; lev = zeros(1,N); m = zeros(1,N); lev(1:2) = levmax; m(1:2) = 1; for l=1:(levmax-1) joff = 2^(levmax-l); lev(joff+1:2*joff)=l; m(joff+1:2*joff) = 1:joff; end I = eye(N); W = zeros(N); for k = 1:N % Wavelet decomp of 1 in k'th sample, 0 otherwise w = I(k,:); for l=1:levmax last = 2^(levmax-l+1); [w(1:last/2) w((last/2+1):last)] = dwt(w(1:last),wname,'mode','per'); end W(k,:) = w(1:N); end W = W'; % Now C = W*s, where s is the signal vector subplot(N/2,2,1); % Stem plot of first half of rows of W for j = 1:N/2 subplot(N/2,2,2*j-1) stem(W(j,:)); axis([0 N -1 1]) if(j==1) type = 'V'; title(['Level-' int2str(levmax) ' ' wname ' wavelets']) else type = 'W'; end text(-1,0,[type '_' int2str(m(j)) '^' int2str(lev(j))]) axis off subplot(N/2,2,2*j) stem(W(j+N/2,:)); axis([0 N -1 1]) type = 'W'; text(-1,0,[type '_' int2str(m(j+N/2)) '^' int2str(lev(j+N/2))]) axis off end