Forums

Plot of Autocorrelation Error using LMS in Matlab

Started by Unknown December 11, 2006
Hi !!

I hope somebody can help !!

N = 8000;  % Number of Samples
n = 0:N-1;

sigmax = 0.01
L = 12
f1 = 101.7
f2 = 142.4
f3 = 231.5
fs = 1000
K = 20  % Number of realizations
cumensq = zeros(K,N)
en1 = zeros(K,N)
  % length of filter coefficients
wn = zeros(1,L);
a = 0.0001;
muhat = 1.00
wmat = zeros(N+1,L); % 8001 filters
wmat(1,:)=wn;
for kk = 1: K % ensemble process
xn =
cos(2*pi*f1/fs*n)+cos(2*pi*f2/fs*n)+cos(2*pi*f3/fs*n)+sigmax*randn(1,N);
xn1 = cos(2*pi*f1/fs*n)+cos(2*pi*f2/fs*n)+cos(2*pi*f3/fs*n);
dn = sin(2*pi*f2/fs*n);
prepad = zeros(1,L-1)
xnlong = [prepad ,xn];
mu = 0.01;
en = zeros(1,N);  % Matrix : Each Row represents one realization :
Column is samples for one Realization

ensq = zeros(1,N)

for k = 1:N  % sample process
    xx= xnlong(L+k-1:-1:k);
    yn(k) = xx*wn';
    en(k)=dn(k)-yn(k);
     wn = wn + mu * en(k)*xx
     %wn = wn + muhat/(a+xx*xx')* en(k)*xx
    %wn = wn + mu*en(k).*xx; % filter update
    wmat(k+1,:) = wn;
    ensq(k)=en(k).*en(k);

end
en1(kk,:)=en
cumensq(kk,:) =ensq;
end
ensemble = sum(cumensq)/K


figure
aut=CalcCovarianceMatrix(en1,1,8000)
stem(aut)

I have trying to get the autocorrelation of the error signal !!

As you could see that sigmax is defined above and the square of sigmax
should give me the variance and the highest peak value on the
autocorrelation plot !!

I believe the xcorr is not working according to my standard so i tried
this CalcCovarianceMatrix()

which is defined as

function R = CalcCovarianceMatrix(SignalVector, timeStart, timeEnd)
N = length(SignalVector(:,1));
% Initialize R.
R_n = zeros(N,N);
% Compute the time averaged auto-correlation matrix.
for TimeIndex = timeStart:timeEnd,
Value = SignalVector(:,TimeIndex)*SignalVector(:,TimeIndex)';
R_n = R_n + Value;
end;
% Scale the Result.
R = R_n/(timeEnd - timeStart + 1);

however i still not able to get this peak value of sigmax squared
(0.01^2)

kindly somebody assist me !!

what the helly pelly is the problem 

thanks 

Muhammad Ali