clear all; close all; clc;
%%% 6.973 HW1 %%%
% A simple equalization script

% Define channel pulse response
p=[0.9 1]; % for simplicity, assume that this is the pulse resopnse after matched filtering in analog domain
sigma2_noise=0.181; % assume unit energy

% Define equalizer parameters
L=10; % equalizer length
delta=4; % equalizer delay

% Make channel Toeplitz matrix
P=convmtx(p',L)';

% Make a delay target vector
delta_vec=[zeros(1,delta-1) 1 zeros(1,size(P,2)-delta)];

% Zero forcing solution
wzfe=delta_vec*P'*(P*P')^-1;

% calcualte equalized pulse response
peqzfe=wzfe*P;

% calculate the mean-square error
sigma2_zfe_res_isi = 1-wzfe*P*delta_vec';
sigma2_zfe_noise_enh = sigma2_noise*sum(wzfe.^2);
sigma2_zfe = sigma2_zfe_res_isi + sigma2_zfe_noise_enh;

figure(1)
hold off;
subplot(211), stem(wzfe);
subplot(212), stem(peqzfe);
disp(wzfe);
disp(peqzfe);


%%% Do the MMSE linear equalizer


% calcualte equalized pulse response


% calculate the mean-square error


%%% Punch the appropriate columns of P matrix to implement the DFE
%%% equalizer (try both ZFE-DFE and MMSE-DFE)
