.专业整理.
仿真作业
.学习帮手.
:亮
S130101083
学号:
.专业整理.
4.17程序
clc; clear; for i=1:500 sigma_v1=0.27; b(1)=-0.8458; b(2)=0.9458; a(1)=-(b(1)+b(2)); a(2)=b(1)*b(2); datlen=500;
rand('state',sum(100*clock)); s=sqrt(sigma_v1)*randn(datlen,1); x=filter(1,[1,a],s); %%
sigma_v2=0.1;
u=x+sqrt(sigma_v2)*randn(datlen,1); d=filter(1,[1,-b(1)],s); %% w0=[1;0]; w=w0; M=length(w0); N=length(u); mu=0.005;
for n=M:N
ui=u(n:-1:n-M+1); y(n)=w'*ui; e(n)=d(n)-y(n); w=w+mu.*conj(e(n)).*ui; w1(n)=w(1); w2(n)=w(2);
ee(:,i)=mean(e.^2,2); end end
ep=mean(ee'); plot(ep);
xlabel('迭代次数');ylabel('MSE');title('学习曲线');
plot(w1); hold; plot(w2);
仿真结果:
.学习帮手.
.专业整理.
0.70.60.50.4MSE学习曲线0.30.20.10050100150200250300迭代次数350400450500
步长0.015仿真结果
.学习帮手.
.专业整理.
步长0.025仿真结果
.学习帮手.
.专业整理.
步长0.005仿真结果
4.18 程序
data_len = 512; %样本序列的长度 trials = 100; %随机试验的次数
A=zeros(data_len,2);EA=zeros(data_len,1); B=zeros(data_len,2);EB=zeros(data_len,1); for m = 1: trials a1 = -0.975; a2 = 0.95;
sigma_v_2 =0.0731;
v = sqrt(sigma_v_2) * randn(data_len, 1, trials);%产生v(n) u0 = [0 0]; num = 1;
den = [1 a1 a2];
Zi = filtic(num, den, u0); %滤波器的初始条件 u = filter(num, den, v, Zi); %产生样本序列u(n)
%(2)用LMS滤波器来估计w1和w2 mu1 = 0.05; mu2 = 0.005;
w1 = zeros(2, data_len);
.学习帮手.