《DSP using MATLAB》示例Example 8.19

代码:

%% ------------------------------------------------------------------------
%%            Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf('        <DSP using MATLAB> Exameple 8.19 \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; Fs = 1/T;                 % set T = 1
OmegaP = (2/T)*tan(wp/2);        % Prewarp(Cutoff) prototype passband freq
OmegaS = (2/T)*tan(ws/2);        % Prewarp(cutoff) prototype stopband freq

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

% Bilinear Transformation:
[b, a] = bilinear(cs, ds, T); [C, B, A] = dir2cas(b, a)

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


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

figure('NumberTitle', 'off', 'Name', 'Exameple 8.19')
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]);

  运行结果:

转载于:https://www.cnblogs.com/ky027wh-sx/p/6721152.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值