时光飞逝,亲朋会一个一个离我们远去,孤独漂泊一阵子后,我们自己也要离开,

代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.22 \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); [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.22 Analog Butterworth lowpass')
set(gcf,'Color','white');
M = 1; % Omega max subplot(2,2,1); plot(ww_s, mag_s/T); 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('Impulse Response'); figure('NumberTitle', 'off', 'Name', 'Problem 8.22 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.22 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.22 Imp & Freq Response')
set(gcf,'Color','white');
t = [0:0.01:80]; subplot(2,1,1); impulse(cs,ds,t); grid on; % Impulse response of the analog filter
axis([0,80,-0.2,0.3]);hold on n = [0:1:80/T]; hn = filter(b,a,impseq(0,0,80/T)); % Impulse response of the digital filter
stem(n*T,hn); xlabel('time in sec'); title ('Impulse 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*Fs,'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.22的更多相关文章

  1. 《DSP using MATLAB》Problem 6.22

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

  2. 《DSP using MATLAB》Problem 5.22

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

  3. 《DSP using MATLAB》 Problem 3.22

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  4. 《DSP using MATLAB》Problem 7.25

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

  5. 《DSP using MATLAB》Problem 3.1

    先写DTFT子函数: function [X] = dtft(x, n, w) %% --------------------------------------------------------- ...

  6. 《DSP using MATLAB》Problem 7.29

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

  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.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

随机推荐

  1. 2019-6-23-WPF-解决弹出模态窗口关闭后,主窗口不在最前

    title author date CreateTime categories WPF 解决弹出模态窗口关闭后,主窗口不在最前 lindexi 2019-06-23 11:48:38 +0800 20 ...

  2. AOP与IOC的概念(即spring的核心)

    a) IOC:Spring是开源框架,使用框架可以使我们减少工作量,提高工作效率并且它是分层结构,即相对应的层处理对应的业务逻辑,减少代码的耦合度.而spring的核心是IOC控制反转和AOP面向切面 ...

  3. windows安装cygwin实现gcc/g++/linux操作等功能

    首先安装cygwin:参照下列博客去cygwin官网下载即可.安装过程中记得勾选需要的安装包,比如gcc/gdb https://blog.csdn.net/qilvmilv/article/deta ...

  4. Windows 设置内网和外网同时使用

    想要电脑同时使用内网和外网必须具备两个网卡,一个是无线网卡一个是本地连接,无线网卡用来连接wifi也就是外网,而本地连接需要网线连接内网,外网是不需要做设置的,我们只需要设置内网即可,鼠标右击电脑右下 ...

  5. python queue, pipe, manage

    线程中的Queue import time import threading import queue import random def putMessage(): for i in "H ...

  6. day25 模块,sys, logging, json, pickle

      Python之路,Day13 = Python基础13 sys模块 sys.argv 命令行参数List,第一个元素是程序本身路径 sys.exit(n) 退出程序,正常退出时exit(0) sy ...

  7. SpringBoot-application:application.yml/配置文件详解

    ylbtech-SpringBoot-application:application.yml/配置文件详解 springboot采纳了建立生产就绪spring应用程序的观点. Spring Boot优 ...

  8. HDU-1852-Beijing 2008-一个神奇的公式求逆元

    As we all know, the next Olympic Games will be held in Beijing in 2008. So the year 2008 seems a lit ...

  9. Python 实现快速排序和随机快速排序

    直接上代码: #快速排序 #coding: utf-8 def quicksort(a,left,right): if(left<right): mid = partition(a,left,r ...

  10. k8s-prometheus监控