I am working on FxLMS Algorithm for noise cancellation what changes i have to do in my code so it work properly
Show older comments
clc;
clear;
M = 16;
mu = 0.001;
f = 1000;
t = 0.01:0.001:0.5;
b = 1:200;
correct = sin(2*pi*t*f);
len = length(correct);
rng(0);
intrupt = 0.002 *randn(len);
x = correct + intrupt;
xref = x;
primary = [0.8 0.6 -0.2 -0.5 -0.1 0.4 -0.05];
y_d = filter(primary,1,x);
secondary = [0.9 0.6 0.1 -0.4 -0.1 0.2 0.1 0.01 0.001];
w = zeros(1,M);
xn = zeros(1,M);
e = zeros(1,M);
xhx =zeros(1,M);
for j = 1:len
xn = [xref(j) xn(1:end-1)];%secondary path adaptive filter
y_Out = sum(w.* xn);%conv of adaptive
y_ldsp = [y_Out secondary(1:end-1)];
y_final = sum(w.* secondary);%here w means weight of ldsp
e(j) = y_d(j) - y_final;
fil_x = [xref(j) secondary(1:end-1)];
LMS_x = [sum(fil_x.*secondary) xhx(1:end-1)];
w = w + mu*e(j)*LMS_x;
end
Accepted Answer
More Answers (0)
Categories
Find more on Adaptive Filters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!