X-Git-Url: https://adrianiainlam.tk/git/?p=4yp.git;a=blobdiff_plain;f=adaptiveCMA.m;h=41b1e484d6ce18e0084157423da2056986192077;hp=084eab45c3739f31742361868db67e8daae51cad;hb=5fae00773184080617ac022c07495d365975e0e1;hpb=427465905320390cebf3d247b8beace19387c70f diff --git a/adaptiveCMA.m b/adaptiveCMA.m index 084eab4..41b1e48 100644 --- a/adaptiveCMA.m +++ b/adaptiveCMA.m @@ -1,4 +1,4 @@ -function adaptFilterOut = adaptiveCMA(rSampled) +function [adaptFilterOut, convergeIdx] = adaptiveCMA(rSampled) %% adaptive filter %% CMA taps = 19; % ODD taps @@ -17,6 +17,7 @@ function adaptFilterOut = adaptiveCMA(rSampled) adaptFilterOut = zeros(numSymbs, 1); converged = 0; convergeCount = 0; + convergeIdx = Inf; for it = 1:numSymbs if it <= (taps - 1) / 2; @@ -30,14 +31,14 @@ function adaptFilterOut = adaptiveCMA(rSampled) xout = sum(hxx .* xp); ex = 1 - abs(xout) ^ 2; - if abs(ex) < 1e-3 + if abs(ex) < 0.01 convergeCount = convergeCount + 1; else convergeCount = 0; end if ~converged && convergeCount >= 10 - converged = 1 - it + converged = 1; + convergeIdx = it; end adaptFilterOut(it) = xout;