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

📄 adaptive_ale.m

📁 用dsp解压mp3程序的算法
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% adaptive_ale.m - Program for implementing ALE with LMS algorithm
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all, close all;
Fs = 8000;

% Adaptive filtering for ALE

randn('seed',2);
n  = sqrt(0.1)*randn(1,500);     % noise with var = 0.1
s = sqrt(2)*sin(2*pi*200*(1:1:500)/Fs);  % signal with power = 1/2
d = s+n;                         % desired signal,d(n)
x = [0 d(1:length(d)-1)];        % input signal to AF, delayed version of d(n) 
N = 16                           % Number of taps of FIR filter
w0 = zeros(1,N);                 % Intial filter coefficients (16-tap)
max_mu_lms = 1/(N*(0.5+0.1));    % Maximum step size
mu_lms = 0.01;                   % LMS step size.
mu_nlms = 0.1;
max_mu_nlms =1;
d = d';
       
% LMS algorithm

Slms = initlms(w0,mu_lms);
[ylms,elms,Slms] = adaptlms(x,d,Slms);
figure(1)
subplot(311); plot(d); title('Sine wave corrupted with noise');
subplot(312); plot(ylms); title('Enhanced sine wave using ALE(LMS)');
subplot(313); plot(elms); title('Error signal(LMS)');
figure(2)
subplot(211);psd(d); title('PSD before ALE filter'); grid on;
subplot(212);psd(ylms);title('PSD after ALE filter(LMS)');grid on;

% Normalized LMS algorithm

Snlms = initnlms(w0,mu_nlms);
[ynlms,enlms,Snlms] = adaptnlms(x,d,Snlms);
figure(3)
subplot(311); plot(d); title('Sine wave corrupted with noise');
subplot(312); plot(ynlms); title('Enhanced sine wave using ALE(NLMS)');
subplot(313); plot(enlms); title('Error signal(NLMS)');
figure(4)
subplot(211);psd(d); title('PSD before ALE filter'); grid on;
subplot(212);psd(ynlms);title('PSD after ALE filter(NLMS)');grid on;
 
% RLS algorithm

w0 = zeros(1,N);         % intial filter coefficients
P0 = 5*eye(N);           % Initial input correlation matrix inverse
lam = 1;                 % Exponential memory weighting factor
Srls = initrls(w0,P0,lam);
[yrls,erls,Srls] = adaptrls(x,d,Srls);
figure(5)
subplot(311); plot(d); title('Sine wave corrupted with noise');
subplot(312); plot(yrls); title('Enhanced sine wave using ALE(RLS)');
subplot(313); plot(erls); title('Error signal(RLS)');
figure(6)
subplot(211);psd(d); title('PSD before ALE filter'); grid on;
subplot(212);psd(yrls);title('PSD after ALE filter(RLS)');grid on;
       
% Determine the convergence rate
       
figure(7);
b = 1/10*ones(1,10);
subplot(311), plot(1:500, filter(b,1,elms.^2));  %title('Sq Error plot for LMS algorithm')
axis([ 0 500 0 1]);
subplot(312), plot(1:500, filter(b,1,enlms.^2)); %title('Sq Error plot for NLMS algorithm')
axis([ 0 500 0 1]);    
subplot(313), plot(1:500, filter(b,1,erls.^2));  %title('Sq Error plot for RLS algorithm')
axis([ 0 500 0 1]);
       
       
       

⌨️ 快捷键说明

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