《DSP using MATLAB》示例Example6.29
代码:
% 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的更多相关文章
- 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 ...
- DSP using MATLAB 示例 Example3.19
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Discrete-time Signa ...
- DSP using MATLAB示例Example3.18
代码: % Analog Signal Dt = 0.00005; t = -0.005:Dt:0.005; xa = exp(-1000*abs(t)); % Continuous-time Fou ...
- 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 ...
- 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 ...
- DSP using MATLAB 示例Example3.17
- 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, ...
- 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 ...
- 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 ...
随机推荐
- css tips —— 在css中完成国际化
前提 在日常处理国际化的时候,通常是将key通过类似intl.xx(key)转换为对应环境的文案,可是如果需要在css中加入对应逻辑应该怎么做呢(比如在after的伪元素中显示不同的文案),毕竟在cs ...
- (转)浅谈SQL Server 对于内存的管理
简介 理解SQL Server对于内存的管理是对于SQL Server问题处理和性能调优的基本,本篇文章讲述SQL Server对于内存管理的内存原理. 二级存储(secondary storage) ...
- 如何使用POST 方法调用服务
一.WCF REST专用POST方法 1.1. 建立WCF REST 方法 [ServiceContract] public interface IBookingBizService { ...
- 获取url参数,替换特殊字符
function GetQueryString(name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)( ...
- jquery中prop和attr的区别
jquery中prop和attr的区别 prop: prop(name|properties|key,value|fn) **概述** 获取在匹配的元素集中的第一个元素的属性值. 随着一些内置属性的D ...
- GitHub:Git的使用
1.下载安装后设置姓名和邮箱地址 $ git config --global user.name "yourGithubName" $ git config --global us ...
- SqlServer中存储过程 returnC#代码处理以及对应的MySQL如何改写
一.SqlServer 中 1. 创建表 create table testuser( id int, --primary key, names ), address ), paw ) ) 2.创建存 ...
- nginx的编译,和简单的配置问题
反向代理常见的lvs.haproxy. 缓存服务常见的.squid.vanish.常见的前端缓存.Apache是多进程的web服务器,Nginx是多线程的web服务器. Nginx的特点,对静态能力强 ...
- Fiddler进行模拟Post提交json数据,总为null解决方式(转)
原文链接:http://www.cnblogs.com/jys509/p/3550598.html Request Headers: User-Agent: FiddlerHost: localhos ...
- asp.net string有多行文字
用如下格式设置