% question 1
MLa = toeplitz([1,1,0,0,0,0,0,0],[1,0,0,0,0,0,0,1]);
MHa = toeplitz([1,-1,0,0,0,0,0,0],[1,0,0,0,0,0,0,-1]);
W1 = [MLa(1:2:8,:);MHa(1:2:8,:)]

% question 2
MLa = toeplitz([1,1,0,0],[1,0,0,1]);
MHa = toeplitz([1,-1,0,0],[1,0,0,-1]);
W = [MLa(1:2:4,:);MHa(1:2:4,:)]
V2 = [W,zeros(4,4);zeros(4,4),eye(4)]
W2 = V2*W1

% question 3
MLa = toeplitz([1,1],[1,1]);
MHa = toeplitz([1,-1,],[1,-1]);
W = [MLa(1:2:2,:);MHa(1:2:2,:)]
V3 = [W,zeros(2,6);zeros(6,2),eye(6)]
W3 = V3*W2

% question 4

W3*W3'

for j = 1:8 
    stem(W3(j,:),'filled')
    disp('Press a key')
    pause
end;
    

% question 5
a = 1/sqrt(2)
MLa = toeplitz([a,a,0,0,0,0,0,0],[a,0,0,0,0,0,0,a]);
MHa = toeplitz([a,-a,0,0,0,0,0,0],[a,0,0,0,0,0,0,-a]);
W1 = [MLa(1:2:8,:);MHa(1:2:8,:)]

% question 2
MLa = toeplitz([a,a,0,0],[a,0,0,a]);
MHa = toeplitz([a,-a,0,0],[a,0,0,-a]);
W = [MLa(1:2:4,:);MHa(1:2:4,:)]
V2 = [W,zeros(4,4);zeros(4,4),eye(4)]
W2 = V2*W1

% question 3
MLa = toeplitz([a,a],[a,a]);
MHa = toeplitz([a,-a,],[a,-a]);
W = [MLa(1:2:2,:);MHa(1:2:2,:)]
V3 = [W,zeros(2,6);zeros(6,2),eye(6)]
W3 = V3*W2

W1*W1'
W2*W2'
W3*W3'