来汉有一月,往日的高温由于最近几个台风沿海登陆影响,今天终于下雨了,凉爽了几个小时。

接着做题。

%% ------------------------------------------------------------------------
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 8.29 \n\n'); banner();
%% ------------------------------------------------------------------------ Fp = 1500; % analog passband freq in Hz
Fs = 2000; % analog stopband freq in Hz
fs = 8000; % 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 = 0.25; % passband ripple in dB
As = 80; % 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 Chebyshev-1 Prototype Filter Calculation:
[cs, ds] = afd_chb2(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.29 Analog Chebyshev-2 lowpass')
set(gcf,'Color','white');
M = 1.2; % Omega max subplot(2,2,1); plot(ww_s/(pi*1000), mag_s); grid on; axis([-16, 16, 0, 1.1]);
xlabel(' Analog frequency in k\pi units'); ylabel('|H|'); title('Magnitude in Absolute');
set(gca, 'XTickMode', 'manual', 'XTick', [-2000, -1500, 0, 1500, 2000, 8000]*0.002);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0001, 0.5, 0.9716, 1]); subplot(2,2,2); plot(ww_s/(pi*1000), 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', [-2000, -1500, 0, 1500, 2000, 8000]*0.002);
set(gca, 'YTickMode', 'manual', 'YTick', [ -80, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['80';' 1';' 0']); subplot(2,2,3); plot(ww_s/(pi*1000), pha_s/pi); grid on; axis([-16, 16, -1.2, 1.2]);
xlabel('Analog frequency in k\pi nuits'); ylabel('radians'); title('Phase Response');
set(gca, 'XTickMode', 'manual', 'XTick', [-2000, -1500, 0, 1500, 2000, 8000]*0.002);
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.29 Digital Chebyshev-2 lowpass')
set(gcf,'Color','white');
M = 2; % Omega max %% Note %%
%% Magnitude of H(z) * T
%% Note %%
subplot(2,2,1); plot(ww/pi, mag/max(mag)); grid on; axis([0, M, 0, 1.1]);
xlabel(' frequency in \pi units'); ylabel('|H|'); title('Magnitude Response');
set(gca, 'XTickMode', 'manual', 'XTick', [0, 0.375, 0.5, 1.0, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [0, 0.0001, 0.5, 0.9716, 1, 5, 10, 550]); 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.375, 0.5, 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.375, 0.5, 1.0, M]);
set(gca, 'YTickMode', 'manual', 'YTick', [-80, -1, 0]);
set(gca,'YTickLabelMode','manual','YTickLabel',['80';' 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.375, 0.5, 1.0, M]);
%set(gca, 'YTickMode', 'manual', 'YTick', [0:5:35]); figure('NumberTitle', 'off', 'Name', 'Problem 8.29 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.29 Imp & Freq Response')
set(gcf,'Color','white');
t = [0 : 0.000125 : 0.01]; subplot(2,1,1); impulse(cs,ds,t); grid on; % Impulse response of the analog filter
axis([0, 0.01, -2000, 3000]);hold on n = [0:1:0.01/T]; hn = filter(b,a,impseq(0,0,0.01/T)); % Impulse response of the digital filter
stem(n*T,hn); xlabel('time in sec'); title (sprintf('Impulse Responses, T=%f',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');

  运行结果:

绝对指标

Chebyshev-2型模拟低通,系统函数串联形式系数

用match-z算法转换成数字低通,系统函数直接形式的系数

直接形式转换成并联形式,系数

Chebyshev-2型模拟低通,幅度谱、相位谱和脉冲响应

数字低通幅度谱、相位谱和群延迟响应

数字低通的零极点图

给定衰减值对应的精确频率值怎么求,暂时还不会,这里不计算了。

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

  1. 《DSP using MATLAB》Problem 7.29

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

  2. 《DSP using MATLAB》Problem 5.30

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

  3. 《DSP using MATLAB》Problem 8.28

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

  4. 《DSP using MATLAB》Problem 8.27

    7月底,又一个夏天,又一个火热的夏天,来到火炉城武汉,天天高温橙色预警,到今天已有二十多天. 先看看住的地方 下雨的时候是这样的 接着做题 代码: %% ----------------------- ...

  5. 《DSP using MATLAB》Problem 8.26

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

  6. 《DSP using MATLAB》Problem 7.27

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

  7. 《DSP using MATLAB》Problem 7.26

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

  8. 《DSP using MATLAB》Problem 7.25

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

  9. 《DSP using MATLAB》Problem 7.24

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

随机推荐

  1. 我写的界面,在ARM上跑

    这个...其实,我对ARM了解并不多,我顶多也就算是知道ARM怎么玩,EMMC干啥,MMU干啥,还有早期的叫法,比如那个NorFlash NandFlash ,然后也就没啥了. 然后写个裸机什么的,那 ...

  2. js实现图片资源、blob、base64的各种场景转换

    文件转babase64 function getImgToBase64(url,callback){//将图片转换为Base64 var canvas = document.createElement ...

  3. 随笔记录 Linux基本操作命令 2019.7.27

    临时关闭防火墙systemctl stop firewalld永久关闭防火墙systemctl disable firewalld 临时关闭selinux安全机制setenforce 0永久关闭sel ...

  4. 数据库MySQL--基础查询

    1.查询字段 查询表某字段:select 字段名 from 表名: 查询表内所有字段:select * from 表名: (当字段和关键字重名是用( ` )着重号区分 ) 2.查询常量值 select ...

  5. uoj49 轴仓库

    题意: n叠箱子排成一线,第i叠箱子坐标为xi,竖直方向叠着ai个箱子. 可以花费+1s左移或右移一位,也可以在瞬间搬起一个位置的箱子,或将怀里的有且仅有一个箱子放下. 任意选择起点s(可以不与xi重 ...

  6. [JZOJ6278] 2019.8.5【NOIP提高组A】跳房子

    题目 题目大意 给你一个矩阵,从\((1,1)\)开始,每次往右上.右.右下三个格子中权值最大的那个跳. 第一行上面是第\(n\)行,第\(m\)列右边是第\(1\)列.反之同理. 有两个操作:跳\( ...

  7. day34 异常处理、断言、socket之ftp协议

    Python之路,Day20 = 异常处理.断言.socket之ftp协议 参考博客:http://www.cnblogs.com/metianzing/articles/7148191.html 异 ...

  8. C++调用JS,JS调用C++

    JS调用C++,通过设置DIID_HTMLDocumentEvents事件,来捕获HTMLWINDOW上的事件,再通过事件对象的get_srcElement得到事件源,从而得到指定元素对象,从而获取元 ...

  9. ZJOI 2006 物流运输 bzoj1003

    题目描述 物流公司要把一批货物从码头A运到码头B.由于货物量比较大,需要n天才能运完.货物运输过程中一般要转停好几个码头.物流公司通常会设计一条固定的运输路线,以便对整个运输过程实施严格的管理和跟踪. ...

  10. 尚学linux课程---6、linux命令介绍

    尚学linux课程---6.linux命令介绍 一.总结 一句话总结: linux中命令的一般格式:命令关键字 选项 参数1 参数2 1.linux基本原则? 一切皆文件 配置文件保存为纯文本格式 2 ...