📄 iir2.m
字号:
%IIR2 Problem 1.2.2
%
% 'ifile.mat' - input file containing:
% I - members of ensemble
% K - iterations
% sigmax - standard deviation of input
% thetaao, thetabo - coefficient vectors of plant
% sigman - standard deviation of measurement noise
% muv, mukappa - convergence factors
%
% 'ofile.mat' - output file containing:
% ind - sample indexes
% MSE - mean-square error
clear all % clear memory
load ifile; % read input variables
N=length(thetaao); % plant and filter den. order
M=length(thetabo)-1; % plant and filter num. order
N1=N+1;
N2=N+2;
M1=M+1; % auxiliary parameters
MSE=zeros(K,1); % prepare to accumulate MSE*I
for i=1:I, % ensemble
X=zeros(M1,1); % initial input vector
D1=zeros(N,1); % desired signal initial memory
kappa=zeros(N,1); % initial reflection coefficients
Dkappa=zeros(N,1); % initial y derivatives with respect to kappa
v=zeros(N1,1); % output coefficients
oldbh=zeros(N1,1); % initial past backward residuals
bh=zeros(N1,1); % initial backward residuals
fh=zeros(N1,1); % initial forward residuals
for l=1:N,
oldbhp(:,l)=zeros(N1,1);
% initial past additional backward residuals
bhp(:,l)=zeros(N1,1);
% initial additional backward residuals
fhp(:,l)=zeros(N1,1);
% initial additional forward residuals
end
x=(rand(K,1)*2-1)*sqrt(3)*sigmax; % input
n=randn(K,1)*sigman; % measurement noise
for k=1:K, % iterations
X=[x(k)
X(1:N)]; % new input vector
d=[thetaao;thetabo]'*[D1;X];
% desired signal sample
fh(N1)=x(k);
for l=1:N,
fh(N1-l)=fh(N2-l)-kappa(N1-l)*oldbh(N1-l);
bh(N2-l)=kappa(N1-l)*fh(N1-l)+oldbh(N1-l);
end
bh(1)=fh(1); % residuals
y=v'*bh; % output sample
e=d+n(k)-y; % error sample
MSE(k)=MSE(k)+e^2; % accumulate MSE*I
D1=[d
D1(1:N-1)]; % new desired signal memory
v=v+muv*e*bh; % new output coefficients
for l=1:N,
fhp(N1,l)=0;
for ll=1:N,
if N1-ll~=l,
fhp(N1-ll,l)=fhp(N2-ll,l)-kappa(N1-ll)*oldbhp(N1-ll,l);
bhp(N2-ll,l)=kappa(N1-ll)*fhp(N1-ll,l)+oldbhp(N1-ll,l);
else,
fhp(l,l)=fhp(l+1,l)-kappa(l)*oldbhp(l,l)+oldbh(l);
bhp(l+1,l)=kappa(l)*fhp(l,l)+oldbhp(l,l)+fh(l);
end
end
bhp(1,l)=fhp(1,l); % additional residuals
Dkappa(l)=v'*bhp(:,l);% y derivatives with respect to kappa
end
kappa=kappa+mukappa*e*Dkappa; % new reflection coefficients
%
% stability test
for l=1:N,
if abs(kappa(l))>(1-eps),
kappa(l)=sign(kappa(l))*(1-eps);
end
end
%
% updated parameters
oldbh=bh;
oldbhp=bhp;
end
end
ind=0:(K-1); % sample indexes
MSE=MSE/I; % calculate MSE
save ofile ind MSE; % write output variables
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -