用match-z方法,将模拟低通转换为数字低通

代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.25 \n\n'); banner();
%% ------------------------------------------------------------------------ % -------------------------------
% ω = ΩT = 2πF/fs
% Digital Filter Specifications:
% -------------------------------
wp = 0.4*pi; % digital passband freq in rad/sec
ws = 0.6*pi; % digital stopband freq in rad/sec
Rp = 0.5; % 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 = 2; % set T = 1
Fs = 1/T;
OmegaP = wp/T; % prototype passband freq
OmegaS = ws/T; % prototype stopband freq % Analog Butterworth Prototype Filter Calculation:
[cs, ds] = afd_butt(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); % Calculation of Impulse Response:
%[ha, x, t] = impulse(cs, ds);
% Impulse Invariance Transformation:
%[b, a] = imp_invr(cs, ds, T); % Calculation of Step Response:
[ha, x, t] = step(cs, ds); % Step Invariance Transformation:
[b, a] = stp_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', 'Problem 8.25 Analog Butterworth lowpass')
set(gcf,'Color','white');
M = 1; % Omega max subplot(2,2,1); plot(ww_s, mag_s); grid on; axis([-M, M, 0, 1.2]);
xlabel(' Analog frequency in \pi units'); ylabel('|H|'); title('Magnitude in Absolute');
set(gca, 'XTickMode', 'manual', 'XTick', [-0.3, -0.2, 0, 0.2, 0.3, 0.4, 0.6]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0032, 0.5, 0.9441, 1]); subplot(2,2,2); plot(ww_s, 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.3, -0.2, 0, 0.4, 0.6]);
set(gca, 'YTickMode', 'manual', 'YTick', [-65, -50, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['65';'50';' 1';' 0']); subplot(2,2,3); plot(ww_s, pha_s/pi); grid on; axis([-M, M, -1.2, 1.2]);
xlabel('Analog frequency in \pi nuits'); ylabel('radians'); title('Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [-0.3, -0.2, 0, 0.4, 0.6]);
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('Step Response'); figure('NumberTitle', 'off', 'Name', 'Problem 8.25 Digital Butterworth lowpass')
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(' frequency in \pi units'); ylabel('|H|'); title('Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.4, 0.6, 1.0, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0032, 0.5, 0.9441, 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.4, 0.6, 1.0, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]); subplot(2,2,3); plot(ww/pi, db); axis([0, M, -100, 10]); grid on;
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB ');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.4, 0.6, 1.0, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-70, -50, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['70';'50';' 1';' 0']); subplot(2,2,4); plot(ww/pi, grd); grid on; %axis([0, M, 0, 35]);
xlabel('frequency in \pi units'); ylabel('Samples'); title('Group Delay');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.4, 0.6, 1.0, M]);
%set(gca, 'YTickMode', 'manual', 'YTick', [0:5:35]); figure('NumberTitle', 'off', 'Name', 'Problem 8.25 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.25 Imp & Freq Response')
set(gcf,'Color','white');
t = [0:0.01:80]; subplot(2,1,1); step(cs,ds,t); grid on; % Step response of the analog filter
axis([0,80,-0.2,1.5]);hold on n = [0:1:80/T]; hn = filter(b,a,stepseq(0,0,80/T)); % Step response of the digital filter
stem(n*T,hn); xlabel('time in sec'); title ('Step Responses');
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,'b+', wwz/(2*pi)*Fs,magz,'r'); grid on; xlabel('frequency in Hz'); title('Magnitude Responses'); ylabel('Magnitude'); text(-0.3,0.15,'Analog filter'); text(0.4,0.55,'Digital filter');

   运行结果:

通带、阻带绝对指标

模拟原型Butterworth低通滤波器,直接形式系数

模拟原型Butterworth低通滤波器,串联形式系数

转换成数字低通后,并联形式系数

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

  1. 《DSP using MATLAB》Problem 7.25

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

  2. 《DSP using MATLAB》示例Example7.25

    今天清明放假的第二天,早晨出去吃饭时天气有些阴,十点多开始“清明时节雨纷纷”了. 母亲远在他乡看孙子,挺劳累的.父亲照顾生病的爷爷…… 我打算今天把<DSP using MATLAB>第7 ...

  3. 《DSP using MATLAB》Problem 7.27

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

  4. 《DSP using MATLAB》Problem 7.14

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

  5. 《DSP using MATLAB》Problem 7.13

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

  6. 《DSP using MATLAB》Problem 6.23

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

  7. 《DSP using MATLAB》Problem 5.24-5.25-5.26

    代码: function y = circonvt(x1,x2,N) %% N-point Circular convolution between x1 and x2: (time domain) ...

  8. 《DSP using MATLAB》Problem 4.21

    快到龙抬头,居然下雪了,天空飘起了雪花,温度下降了近20°. 代码: %% -------------------------------------------------------------- ...

  9. 《DSP using MATLAB》Problem 4.15

    只会做前两个, 代码: %% ---------------------------------------------------------------------------- %% Outpu ...

随机推荐

  1. 查看Linux 内核版本命令

    1.Ubuntu 查看版本命令,三种方法. 1.使用  "uname -a" 2.使用  "lsb_release -a"   3.使用  "cat ...

  2. shell 脚本 功能性语句 read,expr,test

    1. read 从终端输入数据赋值给变量 read val 把读入的数据存放到val中 #!/bin/bash echo -n "please input two number :" ...

  3. JS对象 String 字符串对象定义字符串的方法就是直接赋值。比如: var mystr = "I love JavaScript!"

    String 字符串对象 在之前的学习中已经使用字符串对象了,定义字符串的方法就是直接赋值.比如: var mystr = "I love JavaScript!" 定义mystr ...

  4. JAVA数据结构之二叉树

    用树作为存储数据的结构兼具像数组一样查询速度快和像链表一样具有很快的插入和删除数据项的优点 我们用圆点表示节点,连接圆的直线表示边如下图所示就表示了一颗树,接下来我们讨论的二叉树即每个节点最多只有两个 ...

  5. layer.confirm等事件X关闭与取消监听

    关于layer.confirm的所有操作 layer.confirm('content',{ btn:['确定','取消'], cancel:function(index, layero){ cons ...

  6. Neo4j 因果集群搭建及neo4j-java-driver连接

    搭建Neo4j因果集群 1.下载企业版,当前是3,5,9版本 https://neo4j.com/download-center/#enterprise 2.配置,三个核心集群为例 配置文件,conf ...

  7. U Must Know The .Net --7

    关键字 1 new 创建对象/调用构造函数 隐藏基类成员 new()约束,表明泛型类声明中的任何参数都必须有公共无参构造函数 new 实现多态 1.1 new class:分配内存,调用构造函数实例化 ...

  8. 【JZOJ6368】质树(tree)

    description 大神 wyp 手里有棵二叉树,每个点有一个点权.大神 wyp 的这棵树是质树,因为 随便找两个不同的点 u, v,只要 u 是 v 的祖先,都满足 u 和 v 的点权互质. 现 ...

  9. Spring整合Dubbo框架

    Dubbo作为一个RPC框架,其最核心的功能就是要实现跨网络的远程调用.演示过程创建两个小工程,一个作为服务的提供者,一个作为服务的消费者.通过Dubbo来实现服务消费者远程调用服务提供者的方法. d ...

  10. SGI STL rope

    rope实现的接口可以参考这里. rope是可伸缩的string实现: 它们被设计为用于把string看作一个整体的高效操作 . 比如赋值.串联和子串的操作所花的时间差不多不依赖字符串的长度.与C的字 ...