Professional Documents
Culture Documents
For the NLMS algorithm and FIR filter we used the the filter`s order of 3 and the step 0.2 , while for IIR
filter we used the order 10 and the step 0.001.
In the case of the RLS algorithm , for the FIR type of the filter we used the order 3 and for IIR we used
the order 15.
Codul Matlab :
%%
clear all
close all
clc
N=10000;
miu1 = 0.2;
miu2 = 0.001;
ord1=3;
ord2=10;
x1= randn(N,1);
x2= filter(1,[1,-1.2,0.8],randn(N,1));
d1= filter([1,-1.2,0.8],1,x1);
d2= filter([1,-1.2,0.8],1,x2);
d3= filter(1,[1,-0.8],x1);
d4= filter(1,[1,-0.8],x2);
[W1,E1] = nlms0(x1,d1,miu1,ord1);
[W2,E2] = nlms0(x1,d3,miu2,ord2);
[W3,E3] = nlms0(x2,d2,miu1,ord1);
[W4,E4] = nlms0(x2,d4,miu2,ord2);
%%
clear all
close all
clc
N=10000;
miu = 0.2;
%ord=3;
ord=15;
lam=0.9999;
delta = 0.001;
x1= randn(N,1);
x2= filter(1,[1,-1.2,0.8],randn(N,1));
d1= filter([1,-1.2,0.8],1,x1);
d2= filter([1,-1.2,0.8],1,x2);
d3= filter(1,[1,-0.8],x1);
d4= filter(1,[1,-0.8],x2);
[W5,E5] = rls0(x1,d1,delta,lam,ord);
[W6,E6] = rls0(x1,d3,delta,lam,ord);
[W7,E7] = rls0(x2,d2,delta,lam,ord);
[W8,E8] = rls0(x2,d4,delta,lam,ord);
function [W,E]=nlms0(x,d,miu,ord)
N=length(x);
w=zeros(ord,1);
x1=zeros(ord,1);
E=zeros(N,1);
W=zeros(N,ord);
h = waitbar(0,'Please wait NLMS');
for n=1:N
x1=[x(n);x1(1:ord-1)];
mu=miu/(0.001+norm(x1)^2);
y=w'*x1;
E(n)=d(n)-y;
w=w+mu*x1*E(n)';
W(n,:)=w.';
waitbar(n/N,h)
end
close(h)
Functia rls0 :
function [W,E]=rls0(x,d,delta,lam,ord)
x=x(:);
d=d(:);
P=delta^(-1)*eye(ord);
w=zeros(ord,1);
x1=zeros(ord,1);
N=length(x);
W=zeros(N,ord);
E=zeros(N,1);