《DSP using MATLAB》示例Example 8.13

%% ------------------------------------------------------------------------
%%            Output Info about this m-file
fprintf(‘\n***********************************************************\n‘);
fprintf(‘        <DSP using MATLAB> Exameple 8.13 \n\n‘);

time_stamp = datestr(now, 31);
[wkd1, wkd2] = weekday(today, ‘long‘);
fprintf(‘      Now is %20s, and it is %8s  \n\n‘, time_stamp, wkd2);
%% ------------------------------------------------------------------------

% Digital Filter Specifications:
wp = 0.2*pi;                 % digital passband freq in rad
ws = 0.3*pi;                 % digital stopband freq in rad
Rp = 1;                      % passband ripple in dB
As = 15;                     % stopband attenuation in dB

% Analog prototype specifications: Inverse Mapping for frequencies
T = 1;                       % set T = 1
OmegaP = wp/T;               % prototype passband freq
OmegaS = ws/T;               % prototype stopband freq

% Analog Chebyshev-2 Prototype Filter Calculation:
[cs, ds] = afd_chb2(OmegaP, OmegaS, Rp, As);

% Impulse Invariance Transformation:
[b, a] = imp_invr(cs, ds, T); [C, B, A] = dir2par(b, a)

% Calculation of Frequency Response:
[db, mag, pha, grd, ww] = freqz_m(b, a);

%% -----------------------------------------------------------------
%%                             Plot
%% -----------------------------------------------------------------  

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Exameple 8.13‘)
set(gcf,‘Color‘,‘white‘);
M = 1;                          % Omega max

subplot(2,2,1); plot(ww/pi, mag); axis([0, M, 0, 1.2]); grid on;
xlabel(‘ frequency in \pi units‘); ylabel(‘|H|‘); title(‘Magnitude Response‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [0, 0.2, 0.3, M]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [0, 0.1778, 0.8913, 1]);

subplot(2,2,2); plot(ww/pi, pha/pi); axis([0, M, -1.1, 1.1]); grid on;
xlabel(‘frequency in \pi nuits‘); ylabel(‘radians in \pi units‘); title(‘Phase Response‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [0, 0.2, 0.3, M]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [-1:1:1]);

subplot(2,2,3); plot(ww/pi, db); axis([0, M, -30, 10]); grid on;
xlabel(‘frequency in \pi units‘); ylabel(‘Decibels‘); title(‘Magnitude in dB ‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [0, 0.2, 0.3, M]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [-30, -15, -1, 0]);

subplot(2,2,4); plot(ww/pi, grd); axis([0, M, 0, 15]); grid on;
xlabel(‘frequency in \pi units‘); ylabel(‘Samples‘); title(‘Group Delay‘);
set(gca, ‘XTickMode‘, ‘manual‘, ‘XTick‘, [0, 0.2, 0.3, M]);
set(gca, ‘YTickMode‘, ‘manual‘, ‘YTick‘, [0:5:15]);

  运行结果:

从图中看出,通带和阻带响应都有所降级,因此脉冲不变设计方法不能够得到所需要的数字滤波器。

时间: 2024-10-27 00:46:53

《DSP using MATLAB》示例Example 8.13的相关文章

《DSP using MATLAB》Problem 4.13

代码: %% ---------------------------------------------------------------------------- %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 4.13 \n\n'); banner

《DSP using MATLAB》Problem 5.13

1. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 5.13 \n\n');

《DSP using MATLAB》Problem 8.13

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 8.13 \n\n'); banner();

DSP using MATLAB 示例Example3.21

代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nTs)); Ts = 0.001; n = -5:1:5; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nTs)); % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = x * sinc(Fs*

DSP using MATLAB示例Example3.18

代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fourier Transform Wmax = 2*pi*2000; K = 500; k = 0:1:K; % index array k for frequencies W = k*Wmax/K; % freqency between 0 and +pi, [0,pi] axis divided i

DSP using MATLAB 示例 Example3.19

代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signal Ts = 0.0002; n = -25:1:25; x = exp(-1000*abs(n*Ts)); % Discrete-time Fourier Transform %Wmax = 2*pi*2000; K = 500; k = 0:1:K; w = pi*k/K; % index ar

DSP using MATLAB 示例 Example3.15

上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figure('NumberTitle', 'off', 'Name', 'Input and Output sequence'); set(gcf,'Color','white'); subplot(2,1,1); stem(n,x); title('Input sequence'); xlabel('n'

DSP using MATlAB 示例Example2.10

上代码 % noise sequence 1 x = [3, 11, 7, 0, -1, 4, 2]; nx = [-3:3]; % given signal x(n) [y,ny] = sigshift(x,nx,2); % obtain x(n-2) set(gcf,'Color','white') subplot(2,1,1);stem(nx,x); title('sequence x(n)'); xlabel('n');ylabel('x(n)'); grid on subplot(2,

DSP using MATLAB 示例Example3.17

DSP using MATLAB示例Example3.6

代码: n = [-5:5]; x = (-0.9).^n; % x(n) = k = -200:200; w = (pi/100)*k; % [0,pi] axis divided into 101 points. X = x * (exp(-j*pi/100)) .^ (n'*k); magX = abs(X); angX = angle(X); realX = real(X); imagX = imag(X); set(gcf,'Color','white'); subplot(2,2,1