%wavtrans.m
function [approx detail]=wavtrans(speechsegment,N)
%'N' level Discrete wavelet transformation using 'db6' wavelet.
[LD ,HD,LR,HR]=wfilters('db6')
s=speechsegment;
for i=1:1:N
approx=conv(s,LD);
approx=dyaddown(approx,2);
detail=conv(s,HD);
detail=dyaddown(detail,2);
detailcoef{i}=detail;
s=approx;
end
m=round(sqrt(N+2));
n=round((N+2)/m);
figure
subplot(m,n,1)
plot(speechsegment)
title('Original speech segment')
subplot(m,n,2)
plot(approx)
title(strcat('Approximation in the 0', num2str(N), ' level decomposition'))
for i=1:1:N
subplot(m,n,i+2)
plot(detailcoef{i})
title(strcat('Detail in the 0',num2str(i),' level decomposition'))
end