《DSP using MATLAB》示例Example 6.27
代码:
%
r = 0.9; theta = (pi/180)*[-55:5:-35, 35:5:55]';
p = r*exp(j*theta); a = poly(p); b = 1;
w = [0:500]*pi/500; H = freqz(b*1e-4, a, w);
magH = abs(H); magHdb = 20*log10(magH); % Direct form: quantized coefficients
N = 15; [ahat, L, B] = QCoeff(a, N);
TITLE = sprintf('%i-bit (1+%i+%i) Precision (DF)', N+1, L, B);
Hhat = freqz(b*1e-4, ahat, w); magHhat = abs(Hhat); % Cascade form: quantized coefficients: Same N
[b0, B0, A0] = dir2cas(b, a); [BAhat1, L1, B1] = QCoeff([B0, A0], N);
TITLE1 = sprintf('%i-bit (1+%i+%i) Precision (CF)', N+1, L1, B1);
Bhat1 = BAhat1(:, 1:3); Ahat1 = BAhat1(:, 4:6);
[bhat1, ahat1] = cas2dir(b0, Bhat1, Ahat1);
Hhat1 = freqz(b*1e-4, ahat1, w); magHhat1 = abs(Hhat1); % Cascade fomr: quantized coefficients: Same B (N=L1+B)
N1 = L1 + B; [BAhat2, L2, B2] = QCoeff([B0, A0], N1);
TITLE2 = sprintf('%i-bit (1+%i+%i) Precision (CF)', N1+1, L2, B2);
Bhat2 = BAhat2(:, 1:3); Ahat2 = BAhat2(:, 4:6);
[bhat2, ahat2] = cas2dir(b0, Bhat2, Ahat2);
Hhat2 = freqz(b*1e-4, ahat2, w); magHhat2 = abs(Hhat2); % Comparison of Magnitude Plots
Hf_1 = figure('paperunits', 'inches', 'paperposition', [0, 0, 6, 4]);
%figure('NumberTitle', 'off', 'Name', 'Exameple 6.26a')
set(gcf,'Color','white'); subplot(2, 2, 1); plot(w/pi, magH, 'g', 'linewidth', 2); axis([0, 1, 0, 0.7]);
xlabel('Digital Frequency in \pi units', 'fontsize', 10);
ylabel('Magnitude Response', 'fontsize', 10); grid on;
title('Infinite Precision (DF)', 'fontsize', 10, 'fontweight', 'bold'); subplot(2, 2, 2); plot(w/pi, magHhat, 'r', 'linewidth', 2); axis([0, 1, 0, 0.7]);
xlabel('Digital Frequency in \pi units', 'fontsize', 10);
ylabel('Magnitude Response', 'fontsize', 10); grid on;
title(TITLE, 'fontsize', 10, 'fontweight', 'bold'); subplot(2, 2, 3); plot(w/pi, magHhat1, 'r', 'linewidth', 2); axis([0, 1, 0, 0.7]);
xlabel('Digital Frequency in \pi units', 'fontsize', 10);
ylabel('Magnitude Response', 'fontsize', 10); grid on;
title(TITLE1, 'fontsize', 10, 'fontweight', 'bold'); subplot(2, 2, 4); plot(w/pi, magHhat2, 'r', 'linewidth', 2); axis([0, 1, 0, 0.7]);
xlabel('Digital Frequency in \pi units', 'fontsize', 10);
ylabel('Magnitude Response', 'fontsize', 10); grid on;
title(TITLE2, 'fontsize', 10, 'fontweight', 'bold');
运行结果:
《DSP using MATLAB》示例Example 6.27的更多相关文章
- 《DSP using MATLAB》Problem 7.27
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 5.27
代码: %% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Outp ...
- 《DSP using MATLAB》Problem 8.27
7月底,又一个夏天,又一个火热的夏天,来到火炉城武汉,天天高温橙色预警,到今天已有二十多天. 先看看住的地方 下雨的时候是这样的 接着做题 代码: %% ----------------------- ...
- 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, ...
随机推荐
- Hystrix的正确理解方式
hystrix-logo-tagline-640.png 什么是熔断器 熔断器,原本是电路中在电器发生短路时的防止电路过载的开关装置,它切断发生短路的电路,从而防止因电路过载导致的发热起火等灾难的发生 ...
- jQuery回车键快速切换下一个input文本框解决方案
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- MySQL之长连接、短连接、连接池
当数据库服务器和客户端位于不同的主机时,就需要建立网络连接来进行通信.客户端必须使用数据库连接来发送命令和接收应答.数据.通过提供给客户端数据库的驱动指定连接字符串后,客户端就可以和数据库建立连接了. ...
- 5分钟弄懂Docker
尽管之前久闻Docker的大名了,但是天资愚钝,对其到底是个啥东西一直摸不清,最近花了一段时间整理了一下,算是整理出一点头绪来. 官网的介绍是这样的: Docker is an open platfo ...
- bzoj1009: [HNOI2008]GT考试 ac自动机+矩阵快速幂
https://www.lydsy.com/JudgeOnline/problem.php?id=1009 阿申准备报名参加GT考试,准考证号为N位数X1X2....Xn(0<=Xi<=9 ...
- uva10002凸包重心
把每个三角形看成一个质点,坐标就是各自的重心, #include<map> #include<set> #include<cmath> #include<qu ...
- HDU1595-最短路-删边
find the longest of the shortest Time Limit: 1000/5000 MS (Java/Others) Memory Limit: 32768/32768 ...
- js中删除数组中某一项的方法
1:js中的splice方法 splice(index,len,[item]) 注释:该方法会改变原始数组. splice有3个参数,它也可以用来替换/删除/添加数组内某一个或者几个值 inde ...
- web前端看IE11的变化
一.User-agent的变化 IE11的User-agent Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv 11.0) like Gecko IE10的U ...
- HTML条件注释判断浏览器版本命令
<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--> <!--[if IE]> 所有的IE可识别 <![ ...