LMS算法学习曲线

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

 clear all;close all;clc    %%%%%%%%%%%%%%参数设置%%%%%%%%%%%%%%%%%%%%%%%   step_len=0.05;%步长  variance_v=0.02;%方差  repeat_times=100;%重复次数  iteration_times=500;%迭代次数  filt_len=2;%滤波器长度    %%%%%%%%%%%%%%%%%%%%变量及数组初始化%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Square_err=zeros(repeat_times,iteration_times);   Chan_factor1=[‐0.195 0.95];   X=zeros(filt_len,1);   W1=[];   W2=[];    Wm1=[repeat_times,iteration_times];   Wm2=[repeat_times,iteration_times];     %%%%%%%%%%%%%外循环,重复做repeat_timws次实验,平均值%%%%%%%%%%%%%%%%    for loop1=1:repeat_times%循环次数   %%%%%%%%%%%%%%内循环变量及数组初始化%%%%%%%%%%%%%%%%%%%%%%%%   Source=zeros(iteration_times,1);   W=zeros(filt_len,1);    %%%%%%%%%%%%%内循环,做iteration_times次迭代%%%%%%%%%%%%%%%%%%%%%%%%%%%%   for i=1:iteration_times    %%%%%%%%%%%%%%信源,产生等概率分布的正负1%%%%%%%%%%%%%%%%%%%%%%%%%%%%   if rand0.5    Source(i)=‐1;   else    Source(i)=1;   end   end    %%%%%%%%%%%%%%信道,滤波和加噪 声%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%       Revdata=filter(Chan_factor1,1,Source)+randn(iteration_times,1)*sqrt(variance_v);      % filter the Source      %%%%%%%%%%%%%%均衡器,基于LMS算 法%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   for loop2=1:iteration_times‐filt_len+1   U=Source(loop2:loop2+filt_len‐1);   d=Revdata(loop2+1);    e=d‐W'*U;    W=W+step_len*U*e;   Wm1(loop2,loop1)=W(1);   Wm2(loop2,loop1)=W(2);   Square_err(loop1,loop2)=e.^2;    end    end     %%%%%%%%%%%%%%作图,显示结果%%%%%%%%%%%%%%%%%   Square_err_mean=sum(Square_err(:,:))/repeat_times; % Wm2    W1=Wm1(:,repeat_times);   W2=Wm2(:,repeat_times);   meanW1=mean(Wm1,2);   meanW2=mean(Wm2,2);   Square_err;    %semilogy(Square_err_mean);   figure(1);    plot(Square_err_mean./max(Square_err_mean),'LineWidth',2);   hold on;    suijishu=randperm(repeat_times);    plot(Square_err(suijishu(1),:)./max(Square_err(suijishu(1),:)),'r');   legend([num2str(repeat_times),'次重复试验平均误差'],'单次误差');   xlabel('迭代次数');ylabel('均方误差');title(['步长为 ',num2str(step_len),num2str(iteration_times),'次迭代均方误差变化曲线']);  grid on;  figure(2);    plot(W1);hold on;   plot(W2,'r');hold on;    plot(meanW1,'k');hold on;   plot(meanW2,'‐‐k');    legend('W1','W2',[num2str(repeat_times),'次重复试验W1'],[num2str(repeat_times),'次重复试验W2']);    xlabel('迭代次数');ylabel('抽头权值');title(['步长为 ',num2str(step_len),num2str(iteration_times),'次迭代权值学习曲线']);   grid on;     010020030040050000.10.20.30.40.50.60.70.80.91迭代次数均方误差步长为次迭代均方误差变化曲线0.05500次重复试验平均误差100单次误差 0100200300400500-0.4-0.200.20.40.60.811.2迭代次数抽头权值步长为次迭代权值学习曲线0.05500W1W2次重复试验100W1次重复试验100W2

1 / 5
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功