📄 qrrls2.m
字号:
%QRRLS2 Problem 1.1.1.2.8
%
% '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
% lambda - forgetting factor
%
% 'ofile.mat' - output file containing:
% ind - sample indexes
% M - misadjustment
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
L1=L+1; % auxiliary constant
N=L-1; % plant and filter order
MSE=zeros(K,1); % prepare to accumulate MSE*I
MSEmin=zeros(K,1); % prepare to accumulate MSEmin*I
for i=1:I, % ensemble
X=zeros(L,1); % initial memory
W=zeros(L,1); % initial coefficient vector
v=randn(K,1)*sigmav; % input to AR process
x=filter([1,0],[1,a1],v); % input
n=randn(K,1)*sigman; % measurement noise
dq2p=zeros(L,1);
Up=zeros(L,L);
for k=1:L, % initialization iterations
X=[x(k)
X(1:N)]; % new input vector
Up=lambda^(1/2)*[X'
Up((1:N),:)];
d(k)=Wo'*X+n(k); % noisy desired signal sample
dq2p=lambda^(1/2)*[d(k)
dq2p(1:N)];
ep=d(k)-W'*X; % a priori error sample
MSE(k)=MSE(k)+ep^2; % accumulate MSE*I
MSEmin(k)=MSEmin(k)+(n(k))^2;% accumulate MSEmin*I
W(1)=d(1)/x(1);
if k>1,
for l=2:k,
aux=0;
for ll=2:l,
aux=aux+x(ll)*W(l-ll+1);
end
W(l)=(-aux+d(l))/x(1);
end
end % new coefficient vector
end
for k=L1:K, % iterations
gammap=1;
X=[x(k)
X(1:N)]; % new input vector
xp=X';
d(k)=Wo'*X+n(k); % noisy desired signal sample
dp=d(k);
for l=1:L,
c=sqrt((Up(l,L1-l))^2+(xp(L1-l))^2);
costheta=Up(l,L1-l)/c;
gammap=gammap*costheta;
sintheta=xp(L1-l)/c;
Qthetap=sparse([1 1:(l+1) (l+1):(N+2)]',...
[1 l+1 2:l 1 (l+1):(N+2)]',...
[costheta -sintheta ones(1,l-1) sintheta costheta ones(1,N-(l-1))]',...
N+2,N+2);
AUX=Qthetap*[xp
Up];
xp=AUX(1,:);
Up=AUX(2:L1,:);
AUX=Qthetap*[dp
dq2p];
dp=AUX(1);
dq2p=AUX(2:L1);
end
ep=dp/gammap; % a priori error sample
MSE(k)=MSE(k)+ep^2; % accumulate MSE*I
MSEmin(k)=MSEmin(k)+(n(k))^2; % accumulate MSEmin*I
Up=lambda^(1/2)*Up;
dq2p=lambda^(1/2)*dq2p;
end
end
ind=0:(K-1); % sample indexes
M=MSE./MSEmin-1; % calculate misadjustment
save ofile ind M; % write output variables
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -