代码:

% The following funciton computes the filter
% coefficients shown in Table 6.2
b = firpm(30, [0, 0.3, 0.5, 1], [1, 1, 0, 0]);
w = [0:500]*pi/500; H = freqz(b, 1, w);
magH = abs(H); magHdb = 20*log10(magH); % 16-bit word-length quantization
N1 = 15; [bhat1, L1, B1] = QCoeff(b, N1);
TITLE1 = sprintf('%i-bits (1+%i+%i) ', N1+1, L1, B1);
%bhat1 = bahat(1, :); ahat1 = bahat(2, :);
Hhat1 = freqz(bhat1, 1, w); magHhat1 = abs(Hhat1);
magHhat1db = 20*log10(magHhat1); zhat1 = roots(bhat1); % 8-bit word-length quantization
N2 = 7; [bhat2, L2, B2] = QCoeff(b, N2);
TITLE2 = sprintf('%i-bits (1+%i+%i) ', N2+1, L2, B2);
%bhat2 = bahat(1, :); ahat2 = bahat(2, :);
Hhat2 = freqz(bhat2, 1, w); magHhat2 = abs(Hhat2);
magHhat2db = 20*log10(magHhat2); zhat2 = roots(bhat2); % Comparison of Magnitude Plots
Hf_1 = figure('paperunits', 'inches', 'paperposition', [0, 0, 6, 5], 'NumberTitle', 'off', 'Name', 'Exameple 6.29');
%figure('NumberTitle', 'off', 'Name', 'Exameple 6.26a')
set(gcf,'Color','white'); % Comparison of Log-Magnitude Response: 16 bits
subplot(2, 2, 1); plot(w/pi, magHdb, 'g', 'linewidth', 1.5); axis([0, 1, -80, 5]);
hold on; plot(w/pi, magHhat1db, 'r', 'linewidth', 1); hold off;
xlabel('Digital Frequency in \pi units', 'fontsize', 10);
ylabel('Decibels', 'fontsize', 10); grid on;
title(['Log-mag Plot: ', TITLE1], 'fontsize', 10, 'fontweight', 'bold'); % Comparison of Pole-Zero Plots: 16 bits
subplot(2, 2, 3); [HZ, HP, Hl] = zplane([b], [1]); axis([-2, 2, -2, 2]); hold on;
set(HZ, 'color', 'g', 'linewidth', 1, 'markersize', 4);
set(HP, 'color', 'g', 'linewidth', 1, 'markersize', 4);
plot(real(zhat1), imag(zhat1), 'r+', 'linewidth', 1); grid on;
title(['PZ Plot: ' TITLE1], 'fontsize', 10, 'fontweight', 'bold'); hold off; % Comparison of Log-Magnitude Response: 8 bits
subplot(2, 2, 2); plot(w/pi, magHdb, 'g', 'linewidth', 1.5); axis([0, 1, -80, 5]);
hold on; plot(w/pi, magHhat2db, 'r', 'linewidth', 1); hold off;
xlabel('Digital Frequency in \pi units', 'fontsize', 10);
ylabel('Decibels', 'fontsize', 10); grid on;
title(['Log-mag Plot: ', TITLE2], 'fontsize', 10, 'fontweight', 'bold'); % Comparison of Pole-Zero Plots: 8 bits
subplot(2, 2, 4); [HZ, HP, Hl] = zplane([b], [1]); axis([-2, 2, -2, 2]); hold on;
set(HZ, 'color', 'g', 'linewidth', 1, 'markersize', 4);
set(HP, 'color', 'g', 'linewidth', 1, 'markersize', 4);
plot(real(zhat2), imag(zhat2), 'r+', 'linewidth', 1); grid on;
title(['PZ Plot: ' TITLE2], 'fontsize', 10, 'fontweight', 'bold'); hold off;

运行结果:

《DSP using MATLAB》示例Example6.29的更多相关文章

  1. DSP using MATLAB 示例Example3.21

    代码: % Discrete-time Signal x1(n) % Ts = 0.0002; n = -25:1:25; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*a ...

  2. DSP using MATLAB 示例 Example3.19

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...

  3. DSP using MATLAB示例Example3.18

    代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...

  4. DSP using MATLAB 示例Example3.23

    代码: % Discrete-time Signal x1(n) : Ts = 0.0002 Ts = 0.0002; n = -25:1:25; nTs = n*Ts; x1 = exp(-1000 ...

  5. DSP using MATLAB 示例Example3.22

    代码: % Discrete-time Signal x2(n) Ts = 0.001; n = -5:1:5; nTs = n*Ts; Fs = 1/Ts; x = exp(-1000*abs(nT ...

  6. DSP using MATLAB 示例Example3.17

  7. DSP using MATLAB示例Example3.16

    代码: b = [0.0181, 0.0543, 0.0543, 0.0181]; % filter coefficient array b a = [1.0000, -1.7600, 1.1829, ...

  8. DSP using MATLAB 示例 Example3.15

    上代码: subplot(1,1,1); b = 1; a = [1, -0.8]; n = [0:100]; x = cos(0.05*pi*n); y = filter(b,a,x); figur ...

  9. DSP using MATLAB 示例 Example3.13

    上代码: w = [0:1:500]*pi/500; % freqency between 0 and +pi, [0,pi] axis divided into 501 points. H = ex ...

随机推荐

  1. hand first python 选读(1)

    列表(list) 基本操作 比如说我要整理一个近期热映的电影列表: movies = ["venom", "My Neighbor Totor", " ...

  2. python selenium常用基本方法---H5和键盘鼠标操作

    一.模拟手机打开页面(H5测试) from selenium import webdriver mobile_emulation = {'deviceName':'iPhone X'} options ...

  3. 栈之括号匹配问题(java实现)

    假设表达式中只允许两种括号:().{}:正确表达顺序为:()或{}或({})或{({}{})}的形势:如{(}或(})或({)}的表达形势均不对.算法的设计思想: 出现左括弧则进栈: 出现右括弧则首先 ...

  4. JAVA执行带参数的SQL语句

    转自 http://www.cnblogs.com/raymond19840709/archive/2008/05/12/1192948.html

  5. Java中操作Redis

    一.server端安装 1.下载 https://github.com/MSOpenTech/redis 可看到当前可下载版本:redis2.6 下载后的文件为: 解压后,选择当前64位win7系统对 ...

  6. JS中call和apply区别有哪些 记录

    一.call和apply区别 传递参数的方式.用法上不同,主要是参数不完全同 (1).B.Function.call(A,arg,arg) 这个例子是讲A对象“调用”B对象的Function(某个具体 ...

  7. Python3 flask nginx uwsgi 环境搭建

    配置项目的时候一般使用虚拟环境,是各个项目的环境独立起来,更多方便管理.至于如何使用搜索即可,并不难 1.安装python3 yum -y install zlib-devel bzip2-devel ...

  8. MP3格式音频文件结构解析

    MP3的全称是MPEG Audio Layer3,它是一种高效的计算机音频编码方案,它以较大的压缩比将音频文件转换成较小的扩展名为.MP3的文件,基本保持原文件的音质.MP3是ISO/MPEG标准的一 ...

  9. .NET 方法回调

    使用 AsyncCallback 委托在一个单独的线程中处理异步操作的结果. AsyncCallback 委托表示在异步操作完成时调用的回调方法. 回调方法采用 IAsyncResult 参数,该参数 ...

  10. mstsc Windows局域网内远程桌面连接

    1.检查被连接计算机的远程桌面连接功能是否开启  控制面板->系统和安全->系统->远程设置->远程桌面->勾选"仅允许运行使用网络级别身份验证的远程桌面的计算 ...