clear
clc
h(1,:)=[ 0.25 1 0.25];
h(2,:)=[ 0.25 1 -0.25];
h(3,:)=[-0.25 1 0.25];
a_color=[‘b’,‘g’,‘r’];
figure;
for j=1:3
hi=h(j,:);
N=1500; 00Bit
v=0.001; % buchang
sigma2=0.01; %sigma^2
sigma=sqrt(sigma2); %sigma
e2=zeros(100,N);
for n=1:100 0ci
s=2*randint(1,N)-1;
u=conv(s,hi);
u=u+sigma*randn(1,length(u));
% figure
% subplot(211);stem(s);
% subplot(212);stem(u);
u=[zeros(1,20) u];
w=zeros(1,21)‘;
x=[u(21+12:-1:1+12)]’;
y=w‘*x;
e=x(1)-y;
J=zeros(1,N);
J(13)=e^2;
w=w+v.*x*e;
for i=14:N
x=[u(20+i:-1:i)]’;
y=w‘*x;
d=s(i-12);
e(i)=d-y;
w=w+v.*x*e(i);
J(i)=e(i)^2;
end
e2(n,:)=J;
end;
e2o=mean(e2);
plot(e2o,a_color(j));hold on
end
title([’LMS-e^2(n) /sigma^2=‘,num2str(sigma2)]);grid
xlabel(’n‘);ylabel(’e^2(n)‘)
legend(’H_1(Z)‘,’H_2(Z)‘,’H_3(Z)‘);hold off;
% RLS
% Made by shuimu
% 2014/5/25
clear
clc
h(1,:)=[ 0.25 1 0.25];
h(2,:)=[ 0.25 1 -0.25];
h(3,:)=[-0.25 1 0.25];
a_color=[’b‘,’g‘,’r‘];
lamda=[0.98 0.9 0.75];
sigma2=0.01; %sigma^2
sigma=sqrt(sigma2); %sigma
for m=1:3
v=lamda(m); % yiwang
figure;
for j=1:3
hi=h(j,:);
N=100;
e2=zeros(1,N);
for n=1:100 0ci
s=2*randint(1,N)-1;
u=conv(s,hi);
u=u+sigma*randn(1,length(u));
% figure
% subplot(211);stem(s);
% subplot(212);stem(u);
deta=0.005*var(u);
% deta=var(u)
% Q=deta*eye(21);
P=(1/deta)*eye(21); %initial P(0)
u=[zeros(1,20) u];
w=zeros(1,21)’;
x=[u(21+12:-1:1+12)]‘;
k=v^(-1).*P*x/(1+v^(-1).*x’*P*x); %k(13)
y1=w‘*x;
e=x(13-12)-y1; %e(13)
J=zeros(1,N);
J(13)=e^2;
w=w+k*e;
P=v^(-1).*P-v^(-1).*k*x’*P; %P(13)
y=w‘*x;
for i=14:N
x=[u(20+i:-1:i)]’;
% y=w‘*x;
% d=s(i-12);
% e(i)=d-y;
% w=w+v.*x*e(i);
% J(i)=e(i)^2;
k=v^(-1).*P*x/(1+v^(-1).*x’*P*x);
y1=w‘*x;
e=s(i-12)-y1;
J(i)=e^2;
w=w+k*e;
P=v^(-1).*P-v^(-1).*k*x’*P;
end
e2(n,:)=J;
end;
e2o=mean(e2);
plot(e2o,a_color(j));hold on
end
title([‘RLS-/epsilon^2(n) /lambda=’,num2str(v),‘ /sigma^2=’,num2str(sigma2)]);grid
xlabel(‘n’);ylabel(‘/epsilon^2(n)’)
legend(‘H_1(Z)’,‘H_2(Z)’,‘H_3(Z)’);
end
clear
clc
h(1,:)=[ 0.25 1 0.25];
h(2,:)=[ 0.25 1 -0.25];
h(3,:)=[-0.25 1 0.25];
a_color=[‘b’,‘g’,‘r’];
figure;
for j=1:3
hi=h(j,:);
N=1500; 00Bit
v=0.001; % buchang
sigma2=0.01; %sigma^2
sigma=sqrt(sigma2); %sigma
e2=zeros(100,N);
for n=1:100 0ci
s=2*randint(1,N)-1;
u=conv(s,hi);
u=u+sigma*randn(1,length(u));
% figure
% subplot(211);stem(s);
% subplot(212);stem(u);
u=[zeros(1,20) u];
w=zeros(1,21)‘;
x=[u(21+12:-1:1+12)]’;
y=w‘*x;
e=x(1)-y;
J=zeros(1,N);
J(13)=e^2;
w=w+v.*x*e;
for i=14:N
x=[u(20+i:-1:i)]’;
y=w‘*x;
d=s(i-12);
e(i)=d-y;
w=w+v.*x*e(i);
J(i)=e(i)^2;
end
e2(n,:)=J;
end;
e2o=mean(e2);
plot(e2o,a_color(j));hold on
end
title([’LMS-e^2(n) /sigma^2=‘,num2str(sigma2)]);grid
xlabel(’n‘);ylabel(’e^2(n)‘)
legend(’H_1(Z)‘,’H_2(Z)‘,’H_3(Z)‘);hold off;
% RLS
% Made by shuimu
% 2014/5/25
clear
clc
h(1,:)=[ 0.25 1 0.25];
h(2,:)=[ 0.25 1 -0.25];
h(3,:)=[-0.25 1 0.25];
a_color=[’b‘,’g‘,’r‘];
lamda=[0.98 0.9 0.75];
sigma2=0.01; %sigma^2
sigma=sqrt(sigma2); %sigma
for m=1:3
v=lamda(m); % yiwang
figure;
for j=1:3
hi=h(j,:);
N=100;
e2=zeros(1,N);
for n=1:100 0ci
s=2*randint(1,N)-1;
u=conv(s,hi);
u=u+sigma*randn(1,length(u));
% figure
% subplot(211);stem(s);
% subplot(212);stem(u);
deta=0.005*var(u);
% deta=var(u)
% Q=deta*eye(21);
P=(1/deta)*eye(21); %initial P(0)
u=[zeros(1,20) u];
w=zeros(1,21)’;
x=[u(21+12:-1:1+12)]‘;
k=v^(-1).*P*x/(1+v^(-1).*x’*P*x); %k(13)
y1=w‘*x;
e=x(13-12)-y1; %e(13)
J=zeros(1,N);
J(13)=e^2;
w=w+k*e;
P=v^(-1).*P-v^(-1).*k*x’*P; %P(13)
y=w‘*x;
for i=14:N
x=[u(20+i:-1:i)]’;
% y=w‘*x;
% d=s(i-12);
% e(i)=d-y;
% w=w+v.*x*e(i);
% J(i)=e(i)^2;
k=v^(-1).*P*x/(1+v^(-1).*x’*P*x);
y1=w‘*x;
e=s(i-12)-y1;
J(i)=e^2;
w=w+k*e;
P=v^(-1).*P-v^(-1).*k*x’*P;
end
e2(n,:)=J;
end;
e2o=mean(e2);
plot(e2o,a_color(j));hold on
end
title([‘RLS-/epsilon^2(n) /lambda=’,num2str(v),‘ /sigma^2=’,num2str(sigma2)]);grid
xlabel(‘n’);ylabel(‘/epsilon^2(n)’)
legend(‘H_1(Z)’,‘H_2(Z)’,‘H_3(Z)’);
end
举报