haarS = [1/sqrt(2),1/sqrt(2)]; haarW = [1/sqrt(2),-1/sqrt(2)]; N1=16; X = FilterMatrix(haarS,N1); Phi1 = X([1:2:N1],:); X = FilterMatrix(haarW,N1); Psi1 = X([1:2:N1],:); W1N1 = [Phi1;Psi1] W1N1'*W1N1 N2 = N1/2; X = FilterMatrix(haarS,N2); Phi2 = X([1:2:N2],:); X = FilterMatrix(haarW,N2); Psi2 = X([1:2:N2],:); W1N2 = [Phi2;Psi2] W1N2'*W1N2 % Make W2N1 W2N1 = [W1N2*Phi1;Psi1] W2N1'*W2N1 % Now let's do the five levels with N1 = 1024 clear; haarS = [1/sqrt(2),1/sqrt(2)]; haarW = [1/sqrt(2),-1/sqrt(2)]; Daub4S = [(1+sqrt(3))/sqrt(8),(3+sqrt(3))/sqrt(8),... (3-sqrt(3))/sqrt(8),(1-sqrt(3))/sqrt(8)]; Daub4W = [-(1-sqrt(3))/sqrt(8),(3-sqrt(3))/sqrt(8),... -(3+sqrt(3))/sqrt(8),(1+sqrt(3))/sqrt(8)]; S=Daub4S; W=Daub4W; N1=1024; X1 = FilterMatrix(S,N1); Phi1 = X1([1:2:N1],:); X1 = FilterMatrix(W,N1); Psi1 = X1([1:2:N1],:); N2=N1/2; X2 = FilterMatrix(S,N2); Phi2 = X2([1:2:N2],:); X2 = FilterMatrix(W,N2); Psi2 = X2([1:2:N2],:); N3=N2/2; X3 = FilterMatrix(S,N3); Phi3 = X3([1:2:N3],:); X3 = FilterMatrix(W,N3); Psi3 = X3([1:2:N3],:); N4=N3/2; X4 = FilterMatrix(S,N4); Phi4 = X4([1:2:N4],:); X4 = FilterMatrix(W,N4); Psi4 = X4([1:2:N4],:); N5=N4/2; X5 = FilterMatrix(S,N5); Phi5 = X5([1:2:N5],:); X5 = FilterMatrix(W,N5); Psi5 = X5([1:2:N5],:); W5 = [ Phi5 * Phi4 * Phi3 * Phi2 * Phi1; ... Psi5 * Phi4 * Phi3 * Phi2 * Phi1; ... Psi4 * Phi3 * Phi2 * Phi1; ... Psi3 * Phi2 * Phi1; ... Psi2 * Phi1; ... Psi1]; S = [cos(pi/128*[1:128]),cos(pi*2/128*[1:128]),... cos(4*pi/128*[1:128]),cos(pi*8/128*[1:128]),... cos(16*pi/128*[1:128]),cos(pi*32/128*[1:128]),... cos(64*pi/128*[1:128]),cos(pi*128/128*[1:128])]'; WT = W5*S; Cells=zeros(6,512); Cells(1,[1:16:512]) = WT(1:32); Cells(1,[1:16:512]+1) = WT(1:32); Cells(1,[1:16:512]+2) = WT(1:32); Cells(1,[1:16:512]+3) = WT(1:32); Cells(1,[1:16:512]+4) = WT(1:32); Cells(1,[1:16:512]+5) = WT(1:32); Cells(1,[1:16:512]+6) = WT(1:32); Cells(1,[1:16:512]+7) = WT(1:32); Cells(1,[1:16:512]+8) = WT(1:32); Cells(1,[1:16:512]+9) = WT(1:32); Cells(1,[1:16:512]+10) = WT(1:32); Cells(1,[1:16:512]+11) = WT(1:32); Cells(1,[1:16:512]+12) = WT(1:32); Cells(1,[1:16:512]+13) = WT(1:32); Cells(1,[1:16:512]+14) = WT(1:32); Cells(1,[1:16:512]+15) = WT(1:32); Cells(2,[1:16:512]) = WT(33:64); Cells(2,[1:16:512]+1) = WT(33:64); Cells(2,[1:16:512]+2) = WT(33:64); Cells(2,[1:16:512]+3) = WT(33:64); Cells(2,[1:16:512]+4) = WT(33:64); Cells(2,[1:16:512]+5) = WT(33:64); Cells(2,[1:16:512]+6) = WT(33:64); Cells(2,[1:16:512]+7) = WT(33:64); Cells(2,[1:16:512]+8) = WT(33:64); Cells(2,[1:16:512]+9) = WT(33:64); Cells(2,[1:16:512]+10) = WT(33:64); Cells(2,[1:16:512]+11) = WT(33:64); Cells(2,[1:16:512]+12) = WT(33:64); Cells(2,[1:16:512]+13) = WT(33:64); Cells(2,[1:16:512]+14) = WT(33:64); Cells(2,[1:16:512]+15) = WT(33:64); Cells(3,[1:8:512]) = WT(65:128); Cells(3,[1:8:512]+1) = WT(65:128); Cells(3,[1:8:512]+2) = WT(65:128); Cells(3,[1:8:512]+3) = WT(65:128); Cells(3,[1:8:512]+4) = WT(65:128); Cells(3,[1:8:512]+5) = WT(65:128); Cells(3,[1:8:512]+6) = WT(65:128); Cells(3,[1:8:512]+7) = WT(65:128); Cells(4,[1:4:512]) = WT(129:256); Cells(4,[1:4:512]+1) = WT(129:256); Cells(4,[1:4:512]+2) = WT(129:256); Cells(4,[1:4:512]+3) = WT(129:256); Cells(5,[1:2:512]) = WT(257:512); Cells(5,[1:2:512]+1) = WT(257:512); Cells(6,[1:1:512]) = WT(513:1024);