代码:

% 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. Java网络编程学习A轮_02_抓包分析TCP三次握手过程

    参考资料: https://huoding.com/2013/11/21/299 https://hpbn.co/building-blocks-of-tcp/#three-way-handshake ...

  2. Memory Manager surface area changes in SQL Server 2012

    here were various changes to memory related DMVs, DBCC memory status, and Perfmon counters in SQL Se ...

  3. [java]Stream API——map和flatMap的区别

    map方法 map的含义为映射.是指对于Stream中包含的每一个元素使用给定的转换函数进行转换. map传入的Lambda表达式必须是Function实例,参数可以为任意类型,而其返回值也是任性类型 ...

  4. 解决silk-v3-decoder-master转换wav时,百度语音解析问题

    $cur_dir/silk/decoder >& if [ ! -f "$1.pcm" ]; then /usr/local/ffmpeg/bin/ffmpeg -y ...

  5. Enumerable的判断是否包含某个元素

    // 通过使用默认的相等比较器(即纯粹的对象比较)确定序列是否包含指定的元素. public static bool Contains<TSource>(this IEnumerable& ...

  6. 51nod-1103-抽屉原理

    1103 N的倍数  题目来源: Ural 1302 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题  收藏  关注 一个长度为N的数组A,从A中选出若干个数,使得 ...

  7. nyoj151——中国剩余定理

    生理周期 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 142220   Accepted: 45744 Descripti ...

  8. Shell 变量,Shell echo命令

    一.Shell 变量 定义变量时,变量名不加美元符号($,PHP语言中变量需要),如: your_name="runoob.com" 注意,变量名和等号之间不能有空格,这可能和你熟 ...

  9. Ansible 手册系列 二(安装)

    通过yum(CentOS, RHEL)安装 系统版本: CentOS7.2 yum install ansible -y 通过pip安装 安装easy_install # 安装easy_install ...

  10. vue打包体积优化之旅

    webpack 与 vue 在使用vue开发时,遇到打包后单个文件太大,因而需要分包,不然加载时间太久.虽然尽可能减少请求次数,但是单个包太大也不是好事 思路 组件按需加载 vue-router 的懒 ...