《DSP using MATLAB》Problem 6.20
先放子函数:
- function [C, B, A, rM] = dir2fs_r(h, r);
- % DIRECT-form to Frequency Sampling form conversion
- % ----------------------------------------------------------
- % [C, B, A, rM] = dir2fs_r(h, r)
- % C = Row vector containing gains for parallel sections
- % B = matrix containing numerator coefficients arranged in rows
- % A = matrix containing denominator coefficients arranged in rows
- % h = impulse response vector of an FIR filter
- % rM = r^M factor needed in the feedforward loop
- % r = radius of the circle over which samples are taken (r<1)
- M = length(h); H = fft(h, M);
- magH = abs(H); phaH = angle(H)';
- % check even or odd M
- if (M == 2*floor(M/2))
- L = M/2-1; % M is even
- %A1 = [1, -1, 0; 1, 1, 0];
- A1 = [1, -r, 0; 1, r, 0];
- C1 = [real(H(1)), real(H(L+2))];
- else
- L = (M-1)/2; % M is odd
- %A1 = [1, -1, 0];
- A1 = [1, -r, 0];
- C1 = [real(H(1))];
- end
- k = [1:L]';
- % initialize B and A arrays
- B = zeros(L, 2); A = ones(L, 3);
- % compute denominator coefficients
- A(1:L, 2) = -2*r*cos(2*pi*k/M);
- A(1:L, 3) = r*r;
- A = [A;A1];
- % compute numerator coefficients
- B(1:L,1) = cos(phaH(2:L+1));
- B(1:L,2) = -r*cos(phaH(2:L+1) - (2*pi*k/M));
- % compute gain coefficients
- C = [2*magH(2:L+1), C1]';
- rM = r^M;
再放主函数:
- %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- %% Output Info about this m-file
- fprintf('\n***********************************************************\n');
- fprintf(' <DSP using MATLAB> Problem 6.20 \n\n');
- banner();
- %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- %format long;
- format short;
- fprintf('\n FIR filter DIRECT-form: \n');
- h = [1, 2, 3, 2, 1]/9;
- b = h
- a = 1.0
- fprintf('\nConvert DIRECT-form to PARALLEL-form : \n');
- [C, Bp, Ap] = dir2par(b, a)
- if size(C)==0
- C = 0;
- end
- fprintf('\nConvert DIRECT-form to CASCADE-form : \n');
- [b0, Bc, Ac] = dir2cas(b, a)
- fprintf('\nConvert TF-form to SOS-form : \n');
- [sos, g] = tf2sos(b, a)
- % ----------------------------------------------------------
- % NOTE: linear-phase can not use LATTICE-form
- % ----------------------------------------------------------
- fprintf('\nConvert DIRECT-form to All-Zero LATTICE-form : \n');
- [Klc] = dir2latc(b)
- fprintf('\nConvert DIRECT-form to FREQUENCY-SAMPLE-form 1 : \n');
- [Cfs, Bfs, Afs] = dir2fs(b)
- fprintf('\nConvert DIRECT-form to FREQUENCY-SAMPLE-form 2 : \n');
- r = 0.9;
- [Cfs_r, Bfs_r, Afs_r, rM] = dir2fs_r(b, r)
- % -----------------------------------------
- % START check
- % -----------------------------------------
- n = [0:7];
- delta = impseq(0, 0, 7)
- %format long
- format short
- hcas = casfiltr(b0, Bc, Ac, delta)
- hltc = latcfilt(Klc, delta)
- %hladr = ladrfilt(Klr, Clr, delta)
- hdir = filter(b, a, delta)
- % -------------------------------------------
- % END check
- % -------------------------------------------
运行结果:
《DSP using MATLAB》Problem 6.20的更多相关文章
- 《DSP using MATLAB》Problem 5.20
窗外的知了叽叽喳喳叫个不停,屋里温度应该有30°,伏天的日子难过啊! 频率域的方法来计算圆周移位 代码: 子函数的 function y = cirshftf(x, m, N) %% -------- ...
- 《DSP using MATLAB》Problem 4.20
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 3.20
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 2.20
代码: %% ------------------------------------------------------------------------ %% Output Info about ...
- 《DSP using MATLAB》Problem 7.24
又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...
- 《DSP using MATLAB》Problem 7.23
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...
- 《DSP using MATLAB》Problem 6.15
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.12
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- 《DSP using MATLAB》Problem 6.10
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
随机推荐
- 逆袭之旅DAY.XIA.Object中常用方法
2018-07-31
- Python之路-python基础二
本章内容: 一.编码格式 二.常用数据类型 三.字符串常用方法 四.列表常用方法 五.数据运算 六.课后作业 编码格式: ASCII A ...
- It is never too late!
整理着过去的学习笔记,零零碎碎的,偶尔夹杂着当时的心境. 泛泛的学着东西,不很系统,不很深入,倒像是在拾海,有时捡捡贝壳,有时抓抓螃蟹.叹服大海的神奇,还没来得及深钻某个领域. (以下内容写于2016 ...
- python全栈开发笔记-----------概要
Python开发 开发: 开发语言: 高级语言:python.Java.php .C# .Go .ruby . C++ .... ===>字节码 低级语言:C.汇编 ...
- Django 数据库连接配置(Oracle、Mysql)
一.Django Oracle连接配置 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.oracle', 'NAME': 'DEMO' ...
- vue-4-Class 与 Style 绑定
v-if <h1 v-if="ok">Yes</h1> 切换多个元素://最终的渲染结果不会包含 <template> 元素 <templ ...
- 关于学习Vue的前置工作/技术储备
关于学习Vue的前置工作/技术储备 1.GitBatch 2.Sublime Text 3.Node-----npm 命令 本人用的idea GitBatch: GitBatch是一个可以编写shel ...
- pytorch加载和保存模型
在模型完成训练后,我们需要将训练好的模型保存为一个文件供测试使用,或者因为一些原因我们需要继续之前的状态训练之前保存的模型,那么如何在PyTorch中保存和恢复模型呢? 方法一(推荐): 第一种方法也 ...
- 关于Java课堂实验中的一些总结(Scanner)
import java.util.Scanner; 这个头文件是java里面用来输入东西的,就相当于c++里面的iostream输入流...?暂且这么理解吧 然后使用方法:Scanner in = n ...
- 界面控件DevExpress发布v18.2.5|附下载
DevExpress Universal Subscription(又名DevExpress宇宙版或DXperience Universal Suite)是全球使用广泛的.NET用户界面控件套包,De ...