Prev: can the onboard flash be used to store parameters?
Next: ccs 2.20 don't know how to build hello.c
From: chandrakanthv on 17 Mar 2010 09:22 Hello everyone, I am chandrakanth as can be seen by the user name :). I have a query regarding the implementation of Noise cancellation using NLMS. I have followed the theory from "Statistical DSP by Monson Hayes" I am not able to get the noise cancellation waveforms given in the text book. I am not able to debug the code for the results. Can anyone help me with it. I am pasting the code here. It is written in primitive way with no logical loops etc but still the results do not match. So if possible please go through it and let me know the problem. Thanks and Regards, Chandrkanth. N = 1000; g = randn(1,N); v1(1) = 0; v2(1) = 0; for j = 2:1:N v1(j) = 0.8*v1(j-1) + g(j); v2(j) = -0.6*v2(j-1) + g(j); end sig1 = d + v1(1:N); %sig1 = d + v1(1:1000); x = v2; %-------------------------------- NLMS Algorithm -------------------------- for n = 13:1:N e_sq1(13) = 0; we1(13)= 0; we2(13) = 0; we3(13)= 0; we4(13) = 0; we5(13)= 0; we6(13) = 0; we7(13)= 0; we8(13) = 0; we9(13)= 0; we10(13) = 0; we11(13)= 0; we12(13) = 0; x_est1(n) = we1(n) * x(n-1) + we2(n) * x(n-2)+ we3(n) * x(n-3) + we4(n) * x(n-4)+ we5(n) * x(n-5) + we6(n) * x(n-6) + we7(n) * x(n-7) + we8(n) * x(n-8)+ we9(n) * x(n-9) + we10(n) * x(n-10)+ we11(n) * x(n-11) + we12(n) * x(n-12); e1(n) = sig1(n) - x_est1(n); e_sq(n+1) = e(n) * e(n) + e_sq(n) ; % mean_er(n) = e_sq(n+1)/n; err(n) = d(n) - e1(n); err_sq(n) = (err(n)*err(n)); x_norm1 = x(n-1)*x(n-1); x_conj1 = conj(x(n-1)); x_norm2 = x(n-2)*x(n-2); x_conj2 = conj(x(n-2)); x_norm3 = x(n-3)*x(n-3); x_conj3 = conj(x(n-3)); x_norm4 = x(n-4)*x(n-4); x_conj4 = conj(x(n-4)); x_norm5 = x(n-5)*x(n-5); x_conj5 = conj(x(n-5)); x_norm6 = x(n-6)*x(n-6); x_conj6 = conj(x(n-6)); x_norm7 = x(n-7)*x(n-7); x_norm8 = x(n-8)*x(n-8); x_norm9 = x(n-9)*x(n-9); x_norm10 = x(n-10)*x(n-10); x_norm11 = x(n-11)*x(n-11); x_norm12 = x(n-12)*x(n-12); den = x_norm1 + x_norm2 + x_norm3 + x_norm4 + x_norm5 + x_norm6 + x_norm7 + x_norm8 + x_norm9 + x_norm10 + x_norm11 + x_norm12; we1(n+1) = we1(n) + 0.25 * (e1(n)*(x(n-1)/(den))); we2(n+1) = we2(n) + 0.25 * (e1(n)*(x(n-2)/(den))); we3(n+1) = we3(n) + 0.25 * (e1(n)*(x(n-3)/(den))); we4(n+1) = we4(n) + 0.25 * (e1(n)*(x(n-4)/(den))); we5(n+1) = we5(n) + 0.25 * (e1(n)*(x(n-5)/(den))); we6(n+1) = we6(n) + 0.25 * (e1(n)*(x(n-6)/(den))); we7(n+1) = we7(n) + 0.25 * (e1(n)*(x(n-7)/(den))); we8(n+1) = we8(n) + 0.25 * (e1(n)*(x(n-8)/(den))); we9(n+1) = we9(n) + 0.25 * (e1(n)*(x(n-9)/(den))); we10(n+1) = we10(n) + 0.25 * (e1(n)*(x(n-10)/(den))); we11(n+1) = we11(n) + 0.25 * (e1(n)*(x(n-11)/(den))); we12(n+1) = we12(n) + 0.25 * (e1(n)*(x(n-12)/(den))); end %-------------------------------- NLMS Algorithm -------------------------- figure(2) subplot(4,1,1) plot(d); axis([0 N -3 3]) subplot(4,1,2) plot(sig1); axis([0 N -6 6]) subplot(4,1,3) plot(x); axis([0 N -6 6]) subplot(4,1,4) plot(e1); axis([0 N -3 3]) figure(3) plot(err_sq);
|
Pages: 1 Prev: can the onboard flash be used to store parameters? Next: ccs 2.20 don't know how to build hello.c |