最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

LMS算法程序及注释

来源:动视网 责编:小OO 时间:2025-09-30 08:34:35
文档

LMS算法程序及注释

LMS算法源程序:%channelsystemordersysorder=5;%抽头数%NumberofsystempointsN=2000;%总采样次数inp=randn(N,1);%产生高斯随机序列n=randn(N,1);[b,a]=butter(2,0.25);Gz=tf(b,a,-1);%逆变换函数%ThisfunctionissubmittedtomakeinverseZ-transform(Matlabcentralfileexchange)%Thefirstsysorderwe
推荐度:
导读LMS算法源程序:%channelsystemordersysorder=5;%抽头数%NumberofsystempointsN=2000;%总采样次数inp=randn(N,1);%产生高斯随机序列n=randn(N,1);[b,a]=butter(2,0.25);Gz=tf(b,a,-1);%逆变换函数%ThisfunctionissubmittedtomakeinverseZ-transform(Matlabcentralfileexchange)%Thefirstsysorderwe
LMS算法源程序:

%channel system order

sysorder = 5 ;             %抽头数

% Number of system points 

N=2000;                    %总采样次数

inp = randn(N,1);          %产生高斯随机序列

n = randn(N,1); 

[b,a] = butter(2,0.25); 

Gz = tf(b,a,-1);            %逆变换函数

%This function is submitted to make inverse Z-transform (Matlab central file exchange) 

%The first sysorder weight value 

%h=ldiv(b,a,sysorder)'; 

% if you use ldiv this will give h :filter weights to be 

h= [0.0976; 0.2873; 0.3360; 0.2210; 0.09;];  %信道特性向量

y = lsim(Gz,inp);                              %加入噪声

%add some noise 

n = n * std(y)/(10*std(n));                     %噪声信号

d = y + n;                                      %期望输出信号

totallength=size(d,1);                           %步长

%Take 60 points for training                     %60节点作为训练序列

N=60 ; 

%begin of algorithm                              %算法的开始

w = zeros ( sysorder , 1 ) ;                     %初始化

for n = sysorder : N 

u = inp(n:-1:n-sysorder+1) ;                     % u的矩阵

y(n)= w' * u;                                    %系统输出

e(n) = d(n) - y(n) ;                             %误差

% Start with big mu for speeding the convergence then slow down to reach the correct weights                   %从大的mu加速收敛然后慢下来,以达到正确的权值

if n < 20

mu=0.32; 

else 

mu=0.15; 

end 

w = w + mu * u * e(n) ;               %迭代方程

end 

%check of results                      %检验结果

for n = N+1 : totallength 

u = inp(n:-1:n-sysorder+1) ; 

y(n) = w' * u ; 

e(n) = d(n) - y(n) ;                    %误差

end 

hold on 

plot(d) 

plot(y,'r'); 

title('System output') ;     %系统输出

xlabel('Samples')            %样本

ylabel('True and estimated output')     %实际输出

figure 

semilogy((abs(e))) ;                    % e的绝对值坐标

title('Error curve') ;                  %误差曲线

xlabel('Samples')                       %样本

ylabel('Error value')                    %误差矢量

figure                                   %作图

plot(h, 'k+') 

hold on 

plot(w, 'r*') 

legend('Actual weights','Estimated weights')      %实际权矢量    估计权矢量

title('Comparison of the actual weights and the estimated weights') ;   %比较实际权和估计权矢量

axis([0 6 0.05 0.35]) 

仿真图

文档

LMS算法程序及注释

LMS算法源程序:%channelsystemordersysorder=5;%抽头数%NumberofsystempointsN=2000;%总采样次数inp=randn(N,1);%产生高斯随机序列n=randn(N,1);[b,a]=butter(2,0.25);Gz=tf(b,a,-1);%逆变换函数%ThisfunctionissubmittedtomakeinverseZ-transform(Matlabcentralfileexchange)%Thefirstsysorderwe
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top