Demo entry 6677229

LMS

   

Submitted by anonymous on Dec 03, 2017 at 08:46
Language: Matlab. Code size: 466 Bytes.

function [ w,e ] = LMS( d, y, n, mu )
%LMS 此处显示有关此函数的摘要
%   此处显示详细说明
%   d 为期望响应
%   y 为实际响应
%   n 为滤波器阶数
%   mu 为步长参数
%   w 为输出滤波器系数
%   e 为输出滤波器在各次迭代下的误差

%% 正式函数部分
u = [];
y_expand = [zeros(n-1,1);y];
w = zeros(n,1);
for i = 1:n
    u = [u,y_expand(n+1-i:end+1-i,1)];
end
e = zeros(length(d),1);
for i = 1:length(d)
    y_out = u(i,:)*w;
    e(i,1) = d(i,1) - y_out;
    mu2 = mu/(norm(u(i,:),2)^2);
    w = w + mu2*u(i,:)'*e(i,1);
end
end

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).