# How to use matlab toolbox for 2qam dfe equalizer?

I made Channel equalization with matlab, You can find the code below.

clc; clear all; N = 1e3; MQAM = 2;

d = randi([0 1],N,1);
x = qammod(d,MQAM,'gray','InputType','bit');
h = [0.1 0.5, 0.1 0.2];
r = awgn(complex(filter(h, 1, x), zeros(size(x))), 10, 'measured');

eq = comm.DecisionFeedbackEqualizer;
eq.Constellation = qammod(0:1, 2);
eq.StepSize = maxstep(eq,r);
eq.ReferenceTap = 2;

[y,e,w] = eq(r, x);

dec = qamdemod(y,MQAM,'gray','OutputType','bit');

errors = sum( dec~= d)


For some reasons it is not working and I don't know why the error is still the half of the transmitted symbols number?

I think it is the delay of the equalizer that I am not understanding ... somehow the outputs are delayed and I need to find the correct delay

• I saw your comments, but next time be sure to actually add them as a comment and not an answer. In response, could you put some plots of your resulting constellation and plot the error signal from the equalizer? – Engineer Apr 22 '20 at 1:00

From the MATLAB documentation (https://uk.mathworks.com/help/comm/ref/comm.decisionfeedbackequalizer-system-object.html): "The equalizer uses the reference tap location to track the main energy of the channel". The equalizer object has a property called the reference tap which has default value of one. Looking at your channel coefficients, it looks like the tap with the main energy is the second tap so you should set eq.ReferenceTap = 2.

You can also work on choosing an appropriate step size. The equalizer returns the error signal back, you call it e, you can plot that and use it as a guide to pick a step size. You can also use the in-built function maxstep which gives you the maximum step size needed for a LMS-like algorithm to converge.

Last suggestion I have is unrelated but when calling awgn and the input is real, then the function does not add complex noise so your noise will only appear in the in-phase/real axis. You can get around it just by creating your own complex noise, or by specifying the input as complex with imaginary part equal to zero: r = awgn(complex(filter(h, 1, x), zeros(size(x))), SNR_dB, 'measured').

## Edit

The OP is still having issues so I will add the settings that I use to get results.

eq = comm.DecisionFeedbackEqualizer;
eq.Constellation = qammod(0:MQAM-1, MQAM);
[~, eq.ReferenceTap] = max(h);
eq.StepSize = maxstep(eq, r)/2; % maxstep returns largest so choose something smaller to be safe


And here are the resulting error signal and before/after constellation plot.

• Thank you for your answer and remarks, I've changes the code following your comments but I am still missing something because it still output the same wrong result – user47976 Apr 21 '20 at 23:21
• @Zenofpython Could you put some plots of your resulting constellation and plot the error signal from the equalizer? – Engineer Apr 22 '20 at 11:55