⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 algorithms.m

📁 用dsp解压mp3程序的算法
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% algorithms.m - Program for adaptive system identification using
%                various LMS algorithms:
%                  (i) LMS, (ii) NLMS, (iii)sign-data LMS
%                  (iv) sign-error LMS, (v) sign-sign LMS
%                  (vi) RLS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all, close all;

% Adaptive filter and unknown system used in system ID

       x  = 0.1*randn(1,640); % input signal x(n)
       b  = fir1(31,0.3);     % an unknown FIR system
       d  = filter(b,1,x);    % fesired signal d(n)
       w0 = zeros(1,32);      % intialize filter coefficients (=0)
       mu = 0.75;             % step size for LMS and NLMS
       mu1 = 0.1;             % step size for sign LMSs
       n = [1:640];
       
       % LMS algorith
       Slms = initlms(w0,mu);
       [ylms,elms,Slms] = adaptlms(x,d,Slms);
       
       % Normalized LMS algorithm

       Snlms = initnlms(w0,mu);
       [ynlms,enlms,Snlms] = adaptlms(x,d,Snlms);
              
       % SDLMS algorithm

       Ssd = initsd(w0,mu1);
       [ysd,esd,Ssd] = adaptsd(x,d,Ssd);
       
       % SELMS algorithm

       Sse = initse(w0,mu1);
       [yse,ese,Sse] = adaptse(x,d,Sse);
        
       % SSLMS algorithm

       Sss = initss(w0,mu1);
       [yss,ess,Sss] = adaptss(x,d,Sss);
              
       % RLS algorithm

       w0 = zeros(1,32);      % Intial filter coefficients
       P0 = 5*eye(32);        % Initial input correlation matrix inverse
       lam = 1;               % Exponential memory weighting factor
       Srls = initrls(w0,P0,lam);
       [yrls,erls,Srls] = adaptrls(x,d,Srls);
              
       % Determine the convergence rate
       
       subplot(6,1,1), plot(n, elms);  title('Error plot for LMS algorithm')
       axis([1 640 -0.1 0.1]);
       subplot(6,1,2), plot(n, enlms); title('Error plot for NLMS algorithm')
       axis([1 640 -0.1 0.1]);
       subplot(6,1,3), plot(n, esd);   title('Error plot for sign-data LMS algorithm')
       axis([1 640 -0.1 0.1]);
       subplot(6,1,4), plot(n, ese);   title('Error plot for sign-error LMS algorithm')
       axis([1 640 -0.1 0.1]);
       subplot(6,1,5), plot(n, ess);   title('Error plot for sign-sign LMS algorithm')
       axis([1 640 -0.5 0.5]);
       subplot(6,1,6), plot(n, erls);  title('Error plot for RLS algorithm')
       axis([1 640 -0.1 0.1]);

       
       
       

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -