66 lines
1.6 KiB
Matlab
66 lines
1.6 KiB
Matlab
% Build convolution matrix and solve c such that conv(x,c) approx delta
|
|
x = [0.05; -0.12; 0.3; 1; 0.25; -0.1; 0.04]; % channel pulse response
|
|
Ntaps = 7;
|
|
mu = 0.002;
|
|
Nit = 500;
|
|
|
|
[c, hhist] = peakDistEqualizer(x, Ntaps, mu, Nit);
|
|
|
|
h_eff = conv(x,c);
|
|
|
|
stem(h_eff)
|
|
grid on
|
|
xlabel('Sample index')
|
|
ylabel('Combined impulse response')
|
|
|
|
|
|
function [c, h_hist] = peakDistEqualizer(x, Ntaps, mu, Nit)
|
|
% Peak-distortion / Lucky sign-gradient equalizer
|
|
%
|
|
% x : sampled channel pulse response, main cursor should be near center
|
|
% Ntaps : odd number of equalizer taps
|
|
% mu : step size
|
|
% Nit : number of training iterations
|
|
%
|
|
% c : equalizer coefficients
|
|
% h : combined impulse response h = conv(x,c)
|
|
|
|
x = x(:);
|
|
assert(mod(Ntaps,2)==1, 'Ntaps must be odd');
|
|
|
|
midTap = (Ntaps+1)/2;
|
|
c = zeros(Ntaps,1);
|
|
c(midTap) = 1; % start with through connection
|
|
|
|
h_hist = cell(Nit,1);
|
|
|
|
for it = 1:Nit
|
|
h = conv(x,c);
|
|
h_hist{it} = h;
|
|
|
|
% locate main cursor
|
|
[~, mainIdx] = max(abs(h));
|
|
|
|
% normalize main cursor conceptually
|
|
h = h / h(mainIdx);
|
|
|
|
% update non-center equalizer taps
|
|
for j = 1:Ntaps
|
|
if j == midTap
|
|
continue
|
|
end
|
|
|
|
% map equalizer tap j to corresponding ISI sample
|
|
isiIdx = mainIdx + (j - midTap);
|
|
|
|
if isiIdx >= 1 && isiIdx <= length(h)
|
|
c(j) = c(j) - mu * sign(h(isiIdx));
|
|
end
|
|
end
|
|
|
|
% optional: normalize center/main gain
|
|
h = conv(x,c);
|
|
[~, mainIdx] = max(abs(h));
|
|
c = c / h(mainIdx);
|
|
end
|
|
end |