代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.32 \n\n'); banner();
%% ------------------------------------------------------------------------ % -------------------------------------
% Ω=(2/T)tan(ω/2)
% ω=2*[atan(ΩT/2)]
% Digital Filter Specifications:
% -------------------------------------
wp = 0.3*pi; % digital passband freq in rad
ws = 0.4*pi; % digital stopband freq in rad
Rp = 0.25; % passband ripple in dB
As = 50; % stopband attenuation in dB Ripple = 10 ^ (-Rp/20) % passband ripple in absolute
Attn = 10 ^ (-As/20) % stopband attenuation in absolute % Analog prototype specifications: Inverse Mapping for frequencies
T = 1; % set T = 1
Fs = 1/T;
OmegaP = (2/T)*tan(wp/2) % prototype passband freq
OmegaS = (2/T)*tan(ws/2) % prototype stopband freq % Analog Elliptic Prototype Filter Calculation:
[cs, ds] = afd_elip(OmegaP, OmegaS, Rp, As); % Calculation of second-order sections:
fprintf('\n***** Cascade-form in s-plane: START *****\n');
[CS, BS, AS] = sdir2cas(cs, ds)
fprintf('\n***** Cascade-form in s-plane: END *****\n'); % Calculation of Frequency Response:
[db_s, mag_s, pha_s, ww_s] = freqs_m(cs, ds, 0.5*pi/T); % Calculation of Impulse Response:
[ha, x, t] = impulse(cs, ds); % Impulse Invariance Transformation:
%[b, a] = imp_invr(cs, ds, T); % Bilinear Transformation
[b, a] = bilinear(cs, ds, Fs)
[C, B, A] = dir2cas(b, a) % Calculation of Frequency Response:
[db, mag, pha, grd, ww] = freqz_m(b, a); %% -----------------------------------------------------------------
%% Plot
%% -----------------------------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 8.32 Analog Elliptic lowpass')
set(gcf,'Color','white');
M = 1.0; % Omega max subplot(2,2,1); plot(ww_s/pi, mag_s); grid on; %axis([-10, 10, 0, 1.2]);
xlabel(' Analog frequency in \pi units'); ylabel('|H|'); title('Magnitude in Absolute');
set(gca, 'XTickMode', 'manual', 'XTick', [-0.4625, -0.3244, 0, 0.3244, 0.4625]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0032, 0.9716, 1.0, 1.5]); subplot(2,2,2); plot(ww_s/pi, db_s); grid on; %axis([0, M, -50, 10]);
xlabel('Analog frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB ');
set(gca, 'XTickMode', 'manual', 'XTick', [-0.4625, -0.3244, 0, 0.3244, 0.417, 0.458, 0.4625]);
set(gca, 'YTickMode', 'manual', 'YTick', [-50, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['50';' 1';' 0']); subplot(2,2,3); plot(ww_s/pi, pha_s/pi); grid on; %axis([-10, 10, -1.2, 1.2]);
xlabel('Analog frequency in \pi nuits'); ylabel('radians'); title('Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [-0.4625, -0.3244, 0, 0.3244, 0.4625]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:0.5:1]); subplot(2,2,4); plot(t, ha); grid on; %axis([0, 30, -0.05, 0.25]);
xlabel('time in seconds'); ylabel('ha(t)'); title('Impulse Response'); figure('NumberTitle', 'off', 'Name', 'Problem 8.32 Digital Elliptic lowpass by bilinear')
set(gcf,'Color','white');
M = 2; % Omega max subplot(2,2,1); plot(ww/pi, mag); axis([0, M, 0, 1.2]); grid on;
xlabel(' Digital frequency in \pi units'); ylabel('|H|'); title('Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 1.6, 1.7, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0032, 0.9716, 1]); subplot(2,2,2); plot(ww/pi, pha/pi); axis([0, M, -1.1, 1.1]); grid on;
xlabel('Digital frequency in \pi nuits'); ylabel('radians in \pi units'); title('Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 1.6, 1.7, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]); subplot(2,2,3); plot(ww/pi, db); axis([0, M, -80, 10]); grid on;
xlabel('Digital frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB ');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.37, 0.4, 1.6, 1.7, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-60, -50, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['60';'50';' 1';' 0']); subplot(2,2,4); plot(ww/pi, grd); grid on; %axis([0, M, 0, 35]);
xlabel('Digital frequency in \pi units'); ylabel('Samples'); title('Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.3, 0.4, 1.6, 1.7, M]);
%set(gca, 'YTickMode', 'manual', 'YTick', [0:5:35]); figure('NumberTitle', 'off', 'Name', 'Problem 8.32 Pole-Zero Plot')
set(gcf,'Color','white');
zplane(b,a);
title(sprintf('Pole-Zero Plot'));
%pzplotz(b,a); % ----------------------------------------------
% Calculation of Impulse Response
% ----------------------------------------------
figure('NumberTitle', 'off', 'Name', 'Problem 8.32 Imp & Freq Response')
set(gcf,'Color','white');
t = [0:0.01:90]; subplot(2,1,1); impulse(cs,ds,t); grid on; % Impulse response of the analog filter
axis([0,90,-0.2,0.3]);hold on n = [0:1:90/T]; hn = filter(b,a,impseq(0,0,90/T)); % Impulse response of the digital filter
stem(n*T,hn); xlabel('time in sec'); title (sprintf('Impulse Responses T=%2d',T));
hold off % Calculation of Frequency Response:
[dbs, mags, phas, wws] = freqs_m(cs, ds, 2*pi/T); % Analog frequency s-domain [dbz, magz, phaz, grdz, wwz] = freqz_m(b, a); % Digital z-domain %% -----------------------------------------------------------------
%% Plot
%% ----------------------------------------------------------------- subplot(2,1,2); plot(wws/(2*pi), mags/T,'b', wwz/(2*pi*T), magz, 'r'); grid on; xlabel('frequency in Hz'); title('Magnitude Responses'); ylabel('Magnitude'); text(-0.8,0.15,'Analog filter', 'Color', 'b'); text(0.8,0.4,'Digital filter', 'Color', 'r');

  运行结果:

这里主要放双线性变化法的代码。

通带、阻带绝对指标,模拟滤波器截止频率指标,

模拟Elliptic原型低通滤波器,系统函数串联形式的系数

采用双线性变换法,得到数字Elliptic低通滤波器,系统函数直接形式的系数,转换成串联形式的系数

模拟Elliptic原型低通滤波器,其幅度谱、相位谱和脉冲响应

采用双线性变换法(bilinear)得到数字Elliptic低通滤波器,其幅度谱、相位谱和群延迟响应

数字Elliptic低通系统函数零极点图

模拟原型和数字低通的脉冲响应对比,可见双线性变换法不保留脉冲响应的形态。

使用MATLAB自带ellip函数的运算结果这里就不写了,只放张幅度谱、相位谱和群延迟响应的图,可见和双线性变换法得到的结果相比,区别不大。

《DSP using MATLAB》Problem 8.32的更多相关文章

  1. 《DSP using MATLAB》Problem 5.32

    代码: function [y] = ovrlpadd_v3(x, h, N) %% Overlap-Add method of block convolution %% -------------- ...

  2. 《DSP using MATLAB》Problem 7.32

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  3. 《DSP using MATLAB》Problem 6.8

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  4. 《DSP using MATLAB》Problem 5.28

    昨晚手机在看X信的时候突然黑屏,开机重启都没反应,今天维修师傅说使用时间太长了,还是买个新的吧,心疼银子啊! 这里只放前两个小题的图. 代码: 1. %% ++++++++++++++++++++++ ...

  5. 《DSP using MATLAB》Problem 5.22

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% O ...

  6. 《DSP using MATLAB》Problem 5.10

    代码: 第1小题: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Out ...

  7. 《DSP using MATLAB》Problem 7.27

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  8. 《DSP using MATLAB》Problem 7.26

    注意:高通的线性相位FIR滤波器,不能是第2类,所以其长度必须为奇数.这里取M=31,过渡带里采样值抄书上的. 代码: %% +++++++++++++++++++++++++++++++++++++ ...

  9. 《DSP using MATLAB》Problem 7.25

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

随机推荐

  1. 增量+全量备份SVN服务器

    #!/bin/bash # 获取当前是星期几 DAY=$(date +%w) # 获取当前的日期 DATE=$(date '+%Y-%m-%d-%H-%M') # 获取当前版本库中最新的版本 CURR ...

  2. [转]C# Eval在asp.net中的用法及作用

    原文链接:http://www.cnblogs.com/Mr_JinRui/archive/2010/07/06/1772129.html Eval( " ")和Bind( &qu ...

  3. thinkphp rabc权限总结

    今天晚上把ThinkPHP的权限分配弄明白了,心里的包袱立刻放下了,感觉那个爽啊!稍微记录一下. 背景:CMS系统开发(17do). 项目分组:Admin(后台管理).Home(前台显示). Admi ...

  4. https://vjudge.net/contest/321565#problem/C 超时代码

    #include <iostream> #include <cstdio> #include <queue> #include <algorithm> ...

  5. php相关操作

    array_unshift : 数组头部追加 用法如下: $arr = ['demo','dmoa']; array_unshift($arr,'demob'); //在$arr的前面追加demob ...

  6. centos7 创建桌面快捷方式(chrome,eclipse)

    在将eclipse-SDK-3.7.2-Linux-gtk.tar.gz解压到某个目录下之后,命令行进行如下编辑 vi /usr/share/applications/eclipse.desktop ...

  7. VS2010-MFC(对话框:颜色对话框)

    转自:http://www.jizhuomi.com/software/177.html 颜色对话框大家肯定也不陌生,我们可以打开它选择需要的颜色,简单说,它的作用就是用来选择颜色.MFC中提供了CC ...

  8. 论文阅读-(ECCV 2018) Second-order Democratic Aggregation

    本文是Tsung-Yu Lin大神所作(B-CNN一作),主要是探究了一种无序的池化方法\(\gamma\) -democratic aggregators,可以最小化干扰信息或者对二阶特征的内容均等 ...

  9. HYNB Contest 7:2017 Asia HCMC Vietnam National Programming Contest

    A. Another Query on Array Problem B. Board Covering C. Cumulative Sums 题意 \(A_1=1,A_i=A_{i-1}+sod(A_ ...

  10. sql 根据列名查所属表名

    比如 有一个jueseID字段,想知道这个字段是哪个表里的. 第一步: select * from syscolumns where name = 'jueseID' 第二步: select * fr ...