📄 nlrls2.m
字号:
%NLRLS2 Problem 1.1.1.2.5
%
% 'ifile.mat' - input file containing:
% I - members of ensemble
% K - iterations
% a1 - coefficient of input AR process
% sigmax - standard deviation of input
% Wo - coefficient vector of plant
% sigman - standard deviation of measurement noise
% epsilon - small auxiliary constant
% lambda - forgetting factor
%
% 'ofile.mat' - output file containing:
% ind - sample indexes
% MSNE - mean-square normalized error
clear all % clear memory
load ifile; % read input variables
sigmav=sigmax*sqrt(1-a1^2);
% standard deviation of input to AR process
L=length(Wo); % plant and filter length
N=L-1; % plant and filter order
MSNE=zeros(K,1); % prepare to accumulate MSNE*I
for i=1:I, % ensemble
X=zeros(L,1); % initial memory
v=randn(K,1)*sigmav; % input to AR process
x=filter([1,0],[1,a1],v); % input
n=randn(K,1)*sigman; % measurement noise
%
% initial parameters
deltan=zeros(1,L);
deltaDn=zeros(1,L);
oldebn=zeros(1,L);
sigma2x=epsilon;
sigma2d=epsilon;
for k=1:K, % iterations
X=[x(k)
X(1:N)]; % new input vector
d=Wo'*X+n(k); % noisy desired signal sample
sigma2x=lambda*sigma2x+(x(k))^2; % input signal power
sigma1x=sqrt(sigma2x);
sigma2d=lambda*sigma2d+d^2; % desired signal power
sigmad=sqrt(sigma2d);
%
% initialization
ebn(1)=x(k)/sigma1x;
efn=ebn(1);
en=d/sigmad;
for j=1:L, % orders
%
% auxiliary parameters
oldauxeb=sqrt(1-(oldebn(j))^2);
auxeb=sqrt(1-(ebn(j))^2);
auxef=sqrt(1-efn^2);
deltan(j)=deltan(j)*oldauxeb*auxef+oldebn(j)*efn;
auxdelta=sqrt(1-(deltan(j))^2);
%
% prediction errors
ebn(j+1)=(oldebn(j)-deltan(j)*efn)/auxdelta/auxef;
efn=(efn-deltan(j)*oldebn(j))/auxdelta/oldauxeb;
%
% feedforward filtering
deltaDn(j)=deltaDn(j)*auxeb*sqrt(1-en^2)+en*ebn(j);
auxdeltaD=sqrt(1-(deltaDn(j))^2);
en=(en-deltaDn(j)*ebn(j))/auxeb/auxdeltaD;
end
MSNE(k)=MSNE(k)+en^2; % accumulate MSNE*I
%
% updated parameter
oldebn=ebn;
end
end
ind=0:(K-1); % sample indexes
MSNE=MSNE/I; % calculate misadjustment
save ofile ind MSNE; % write output variables
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -