7月底,又一个夏天,又一个火热的夏天,来到火炉城武汉,天天高温橙色预警,到今天已有二十多天。

先看看住的地方

下雨的时候是这样的

接着做题

代码:

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.27 \n\n'); banner();
%% ------------------------------------------------------------------------ Fp = 100; % analog passband freq in Hz
Fs = 150; % analog stopband freq in Hz
fs = 1000; % sampling rate in Hz % -------------------------------
% ω = ΩT = 2πF/fs
% Digital Filter Specifications:
% -------------------------------
wp = 2*pi*Fp/fs; % digital passband freq in rad/sec
%wp = Fp;
ws = 2*pi*Fs/fs; % digital stopband freq in rad/sec
%ws = Fs;
Rp = 1.0; % passband ripple in dB
As = 30; % 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/fs; % set T = 1
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, 2*pi/T); % Calculation of Impulse Response:
[ha, x, t] = impulse(cs, ds); % Match-z Transformation:
%[b, a] = imp_invr(cs, ds, T) % digital Num and Deno coefficients of H(z)
[b, a] = mzt(cs, ds, T) % digital Num and Deno coefficients of H(z)
[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.27 Analog Butterworth lowpass')
set(gcf,'Color','white');
M = 1.2; % Omega max subplot(2,2,1); plot(ww_s/pi*T, mag_s); grid on; axis([-1.5, 1.5, 0, 1.1]);
xlabel(' Analog frequency in k\pi units'); ylabel('|H|'); title('Magnitude in Absolute');
set(gca, 'XTickMode', 'manual', 'XTick', [-500, -300, 0, 200, 300, 1000]*T);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0316, 0.5, 0.8913, 1]); subplot(2,2,2); plot(ww_s/pi*T, db_s); grid on; %axis([0, M, -50, 10]);
xlabel('Analog frequency in k\pi units'); ylabel('Decibels'); title('Magnitude in dB ');
%set(gca, 'XTickMode', 'manual', 'XTick', [-0.3, -0.2, 0, 0.2, 0.3, 1.0]);
set(gca, 'YTickMode', 'manual', 'YTick', [-65, -30, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['65';'30';' 1';' 0']); subplot(2,2,3); plot(ww_s/pi*T, pha_s/pi); grid on; axis([-1.010, 1.010, -1.2, 1.2]);
xlabel('Analog frequency in k\pi nuits'); ylabel('radians'); title('Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [-0.3, -0.2, 0, 0.2, 0.3, 1.0]);
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.27 Digital Butterworth lowpass')
set(gcf,'Color','white');
M = 2; % Omega max %% Note %%
%% Magnitude of H(z) * T
%% Note %%
subplot(2,2,1); plot(ww/pi, mag/fs); axis([0, M, 0, 1.1]); grid on;
xlabel(' frequency in \pi units'); ylabel('|H|'); title('Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.2, 0.3, 1.0, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0316, 0.5, 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, 1.0, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-1:1:1]); subplot(2,2,3); plot(ww/pi, db); axis([0, M, -120, 10]); grid on;
xlabel('frequency in \pi units'); ylabel('Decibels'); title('Magnitude in dB ');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.2, 0.3, 1.0, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-70, -30, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['70';'30';' 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.2, 0.3, 1.0, M]);
%set(gca, 'YTickMode', 'manual', 'YTick', [0:5:35]); figure('NumberTitle', 'off', 'Name', 'Problem 8.27 Pole-Zero Plot')
set(gcf,'Color','white');
zplane(b,a);
title(sprintf('Pole-Zero Plot'));
%pzplotz(b,a); % Calculation of Impulse Response:
%[hs, xs, ts] = impulse(c, d);
figure('NumberTitle', 'off', 'Name', 'Problem 8.27 Imp & Freq Response')
set(gcf,'Color','white');
t = [0:0.001:0.07]; subplot(2,1,1); impulse(cs,ds,t); grid on; % Impulse response of the analog filter
axis([0, 0.07, -100, 250]);hold on n = [0:1:0.07/T]; hn = filter(b,a,impseq(0,0,0.07/T)); % Impulse response of the digital filter
stem(n*T,hn); xlabel('time in sec'); title (sprintf('Impulse Responses, T=%.3f',T));
hold off %n = [0:1:29];
%hz = impz(b, a, n); % 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
%% ----------------------------------------------------------------- M = 1/T; % Omega max 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(1.4,.5,'Analog filter'); text(1.5,1.5,'Digital filter');

  运行结果:

绝对指标

非归一化Butterworth模拟低通直接形式的系数

模拟低通串联形式的系数

开始Match-z方法,转变成数字低通

数字低通直接形式的系数

数字低通的并联形式的系数

模拟Butterworth低通的幅度谱、相位谱和脉冲响应

经过Match-z方法得到的数字Butterworth低通的幅度谱、相位谱和群延迟

数字Butterworth低通的零极点图

模拟Butterworth低通、Match-z方法得到的数字Butterworth低通,二者的脉冲响应、幅度响应如下

从上图可以看出,Match-z方法得到的数字低通,其脉冲响应与原模拟脉冲响应似乎有延迟的效果;其不像脉冲响应不变法那样,数字低通的

脉冲响应是相应模拟低通脉冲响应的采样序列,即保持了脉冲响应形式不变。

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

  1. 《DSP using MATLAB》Problem 7.27

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

  2. 《DSP using MATLAB》Problem 5.27

    代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Outp ...

  3. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  4. 《DSP using MATLAB》Problem 7.16

    使用一种固定窗函数法设计带通滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...

  5. 《DSP using MATLAB》Problem 7.38

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

  6. 《DSP using MATLAB》Problem 7.36

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

  7. 《DSP using MATLAB》Problem 7.32

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

  8. 《DSP using MATLAB》Problem 7.31

    参照Example7.27,因为0.1π=2πf1   f1=0.05,0.9π=2πf2   f2=0.45 所以0.1π≤ω≤0.9π,0.05≤|H|≤0.45 代码: %% +++++++++ ...

  9. 《DSP using MATLAB》Problem 7.26

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

随机推荐

  1. 防止xss漏洞-编码转义

    用JS进行转义还是用PHP进行转义,最后存入数据库的是什么形式 比如:用户输入: <script>alrt(0);</script>那数据库里面存储的是源数据还是转以后的数据: ...

  2. 《创新者》读书笔记 PB16110698 第五周(~4.5)

    本周我阅读了某同学推荐的<创新者>,这本书实际上是两个世纪以来信息技术的编年史,从巴贝奇的差分机到如今互联网时代的超级计算机,作者通过各个时代里一位位杰出的创新者,将计算机诞生.发展.崛起 ...

  3. SpringMVC常用注解知识总结

    1.@Controller 注解到类名上,表示该类是控制器. 2.@RequestMapping("/xxxx") 可以放在类名/方法名之上,表示访问请求该方法时的url.如果该方 ...

  4. 解决vs code 内置终端,字体间隔过大问题。(linux centos7 ubuntu成功)

    去文件-首选项-设置里修改. "terminal.integrated.fontFamily": ""注意此处默认为空白,所以显示的就比较奇怪. 此处我改为&q ...

  5. JS去重算法

    1.遍历数组法 它是最简单的数组去重方法(indexOf方法) 实现思路:新建一个数组,遍历去要重的数组,当值不在新数组的时候(indexOf为-1)就加入该新数组中: var arr=[2,8,5, ...

  6. MQTT--笔记

    一.MQTT协议基本介绍 1.1.MQTT是什么? MQTT,全称为Message Queue Telemetry Transport.在1999年,由IBM的Andy Stanford-Clark和 ...

  7. Linux tee命令使用详解分享

    tee命令主要被用来向standout(标准输出流,通常是命令执行窗口)输出的同时也将内容输出到文件,下面是tee的man 信息 read from standard input and write ...

  8. java基本类型映射表

  9. tomcat8乱码问题

    1:注册表里修改  1):找到 HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe 如果 该项下已存在CodePage项,则把值改为十进制” ...

  10. [NOI 2018]冒泡排序

    题意:求所有字典序大于给定序列且满足条件的排列个数之和. 思路: 考虑dp即可,打表出卡特兰数优化,直接dp可以44... #include <bits/stdc++.h> using n ...