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

📄 e6422exer1.m

📁 these code are about adaptive filter.
💻 M
字号:
%
% ****  Some MATLAB routines for E6422 - Adaptive SP ****
%
%

clear all;

%   -----  Example 1:  16 point FIR filter (e.g. in Figure 2.1(a)) ---------
%

firco = [-0.0031 0.0014 0.0134 0.0022 -0.0521 -0.0376 0.1655 0.4104 0.4104 0.1655 -0.0376 -0.0521 0.0022 0.0134 0.0014 -0.0031];
        
% 1.1 obtain FIR filter transfer function using the z-transform ....

ff = [-0.5: 0.01 : 0.5]  ;    % 101 frequency points in the interval -0.5 < f < 0.5

hh = zeros(1,101) ;

for kk = 1: length(firco)
   hh = hh + firco(kk)*exp(-2*(kk-1)*j*pi*ff) ;
end;

figure(1); plot(ff, abs(hh)) ; grid;
xlabel('Normalized Frequency');
ylabel('Amplitude (units)');
title('FIR: Amplitude Transfer Function - via z-transform');

figure(2); plot(ff, angle(hh)) ; grid;
xlabel('Normalized Frequency');
ylabel('Phase (radians)');
title('FIR: Phase Transfer Function via z-transform');

%
% 1.2 Use filter Impulse response to obtain the filter transfer function
%         NOTE: FIR filter impulse response is same as the filter coefficients ....
%

figure(3); plot(firco) ; grid;    % This is FIR filter impulse response ...

figure(4); plot(ff,fftshift(abs(fft(firco,101)))); grid ;
xlabel('Normalized Frequency');
ylabel('Amplitude (units)');
title('FIR: Amplitude Transfer Function - via FFT');


%
%   -----  Example 2:  4th order IIR filter (e.g. in Figure 2.1(b)) ---------
%

iirco = [-0.2 0.3 0.4 0.1];

% 2.1 obtain IIR filter transfer function using the z-transform ....
        
hh = ones(1,101) ;

for kk = 1: length(iirco)
   hh = hh + iirco(kk)*exp(-2*kk*j*pi*ff) ;
end;

figure(5); plot(ff, ones(1,101)./abs(hh)) ; grid;
xlabel('Normalized Frequency');
ylabel('Amplitude (units)');
title('IIR: Amplitude Transfer Function - via z-transform');

figure(6); plot(ff, angle(-hh)) ; grid;
xlabel('Normalized Frequency');
ylabel('Phase (radians)');
title('IIR: Phase Transfer Function via z-transform');

%
% 2.2 Use filter Impulse response to obtain the filter transfer function
%         First calculate the filter impulse response ....
%

del = zeros(1, length(iirco)) ;

im_res(1) = 1.0 ;

for mm=2:1024
   del = [im_res(mm-1), del(1:length(iirco)-1)] ;
   im_res(mm) = -iirco*del' ;
end;

figure(7); plot(im_res(1:100)) ; grid;   % This is IIR filter impulse response ...

figure(8); plot([-511:512]/1024,fftshift(abs(fft(im_res,1024)))); grid ;
xlabel('Normalized Frequency');
ylabel('Amplitude (units)');
title('IIR: Amplitude Transfer Function - via FFT');


⌨️ 快捷键说明

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