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

代码:

%% ------------------------------------------------------------------------
%% 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. 2018-2-13-win10-uwp-上传Nuget-让别人用我们的库

    title author date CreateTime categories win10 uwp 上传Nuget 让别人用我们的库 lindexi 2018-2-13 17:23:3 +0800 2 ...

  2. arm-linux-copydump 的使用

    生成可以执行的 2 进制代码 [arm@localhost gcc]#arm­linux­copydump ­O binary hello hello.bin

  3. delphi 还原窗口

    1.格局还原procedure TFrmStyleProp.btnNewClick(Sender: TObject); //声明var iniFile : TIniFile; idx : intege ...

  4. SUBTRACT

    SUBTRACT 给出一个长度为n序列\(\{a_i\}\),定义一个操作,记做\(con(a,i)\),意思是用\(a_i-a_{i+1}\)替代\(a_i,a_{i+1}\),显然最后一个数字不能 ...

  5. Qt Creator配置

    1.安装Git sudo apt install git 2.配置Git 用户和邮箱: git config --global user.name "xxx" git config ...

  6. iOS ARC下命名规则

    当我在ARC模式下写以下代码的时候,编译器报错 Semantic Issue: Property's synthesized getter follows Cocoa naming conventio ...

  7. JAVA入门各种API参考

    java sdk: https://docs.oracle.com/javase/8/docs/api/ servlet api: http://tomcat.apache.org/tomcat-8. ...

  8. vue项目实现按需加载的3种方式

    vue异步组件技术 vue-router配置路由,使用vue的异步组件技术,可以实现按需加载.这种方式下一个组件生成一个js文件 用例: { path: '/promisedemo', name: ' ...

  9. iOS逆向系列-脱壳

    概述 通过iOS逆向系列-逆向App中使用class-dump工具导出App的Mach-O文件所有头文件.Hopper工具分析App的Mach-O文件代码大概实现.但是这些前体是App的Mach-O没 ...

  10. printk函数

    一个不同是 printk 允许你根据消息的严重程度对其分类, 通过附加不同的记录级别或者 优先级在消息上. 你常常用一个宏定义来指示记录级别. 例如, KERN_INFO, 我们之前曾 在一些打印语句 ...