?? nlms1.m
字號:
%NLMS1 Problem 3.3
%
% 'ifile.mat' - input file containing:
% I - members of ensemble
% K - iterations
% s - deterministic part of signal to predict
% sigman - standard deviation of noise in signal to predict
% ND - delayer order
% N - filter order
% gamma - small constant to avoid division by 0
% mun - convergence factor
%
% 'ofile.mat' - output file containing:
% ind - sample indexes
% MSE - mean-square error
clear all % clear memory
load ifile; % read input variables
LD=ND+1; % delayer length
L=N+1; % filter length
MSE=zeros(K,1); % prepare to accumulate MSE*I
for i=1:I, % ensemble
D=zeros(LD,1); % initial delayer memory
X=zeros(L,1); % initial memory
Wpr=zeros(L,1); % initial coefficient vector
n=randn(K,1)*sigman; % noise in signal to predict
for k=1:K, % iterations
d=s(k)+n(k); % sample of signal to predict
D=[d
D(1:ND)]; % new delay vector
X=[D(LD)
X(1:N)]; % new input vector
y=Wpr'*X; % output sample
e(k)=d-y; % error sample
Wpr=Wpr+mun/(gamma+X'*X)*e(k)*X;
% new coefficient vector
MSE(k)=MSE(k)+(e(k))^2; % accumulate MSE*I
end
end
ind=0:(K-1); % sample indexes
MSE=MSE/I; % calculate MSE
save ofile ind MSE; % write output variables
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -