代码:

% 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. 织梦dedecms获取当前内容页栏目id号的方法

    一,可在内容模板中直接这样写{dede:field.typeid/} 可显示本栏目的id 二,也可这样写 {dede:type}[field:ID /]{/dede:type}  . 三, 如果是在{ ...

  2. CSS布局框架 960GS

    1.960GS 特点 小巧简单,功能单一(仅仅做排版的工作,其他东西靠自己.)(三个文件:reset.css,960.css,font.css) 界面宽960px,适合目前主流1/2以上显示器都满屏宽 ...

  3. linux命令详解(一)

    linux命令 在使用linux环境进行工作和学习中,我们更多时间是手指在键盘上跳动.这里,我们就来说linux命令使用吧在linux环境中,显然不能记下所有的命令及其使用规则,那么这时,man,he ...

  4. DOM: EVENT FLOW

    捕获阶段(capture phase) 捕获阶段的定义如下(w3c):The event object propagate through the target's ancestors from th ...

  5. 重新学习MySQL数据库6:浅谈MySQL的中事务与锁

    『浅入深出』MySQL 中事务的实现 在关系型数据库中,事务的重要性不言而喻,只要对数据库稍有了解的人都知道事务具有 ACID 四个基本属性,而我们不知道的可能就是数据库是如何实现这四个属性的:在这篇 ...

  6. CSU-1307-二分+dij

    1307: City Tour Submit Page   Summary   Time Limit: 1 Sec     Memory Limit: 128 Mb     Submitted: 59 ...

  7. Hibernate入门_增删改查

    一.Hibernate入门案例剖析:  ①创建实体类Student 并重写toString方法 public class Student { private Integer sid; private ...

  8. vue请求本地json数据

    1.下载vue-resource插件 cnpm install vue-resource 1.2全局引入vue-resource: 在main.js import VueResource from ' ...

  9. css3之calc()

    初识calc() 在使用calc()之前,我也只是听说有这么一个东西,但在用过之后我才发现这个功能其实很实用. calc()其实就是英文calculate(计算)的缩写,它看起来像个函数吧? 其实不是 ...

  10. TCP/IP网路协议复习

    1.OSI (Open System Interconnect Protocol) 开放互联协议,这是一个七层的计算机网络协议,包括:物理层.数据链路层.网络层.传输层.回话层.表示层.应用层.    ...