1 function [adaptFilterOut, convergeIdx] = adaptiveCMA(rSampled)
6 %% hxx: real indices -K, ..., 0, ..., K. K = floor(taps/2)
7 %% MATLAB indices 1 1+K taps
8 %% initialize hxx, hxx[0] = 1, hxx[k] = hxx[-k] = 0
12 numSymbs = length(rSampled);
14 %% Check average energy of symbols
15 rSampledUnitEnergy = normalizeEnergy(rSampled, numSymbs, 1);
17 adaptFilterOut = zeros(numSymbs, 1);
23 if it <= (taps - 1) / 2;
24 xp = [zeros((taps - 1) / 2 - it + 1, 1); rSampledUnitEnergy(1:it + (taps - 1) / 2)];
25 elseif it + (taps - 1) / 2 > numSymbs
26 xp = [rSampledUnitEnergy(it - (taps - 1) / 2 : end); zeros(it + (taps - 1) / 2 - numSymbs, 1)];
28 xp = rSampledUnitEnergy(it - (taps - 1) / 2 : it + (taps - 1) / 2);
31 xout = sum(hxx .* xp);
32 ex = 1 - abs(xout) ^ 2;
35 convergeCount = convergeCount + 1;
39 if ~converged && convergeCount >= 10
44 adaptFilterOut(it) = xout;
46 hxx = hxx + mu * ex * xout * conj(xp);
50 %% try MATLAB builtin equalizer
52 eqObj = lineareq(taps, alg);
53 eqObj.Weights((taps + 1) / 2) = 1;
54 rPadded = [rSampledUnitEnergy; zeros((taps - 1) / 2, 1)];
55 matlabEq = equalize(eqObj, rPadded);
56 matlabEq = matlabEq((taps + 1) / 2 : end);