先放子函数:

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的更多相关文章

  1. 《DSP using MATLAB》Problem 5.20

    窗外的知了叽叽喳喳叫个不停,屋里温度应该有30°,伏天的日子难过啊! 频率域的方法来计算圆周移位 代码: 子函数的 function y = cirshftf(x, m, N) %% -------- ...

  2. 《DSP using MATLAB》Problem 4.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  3. 《DSP using MATLAB》Problem 3.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  4. 《DSP using MATLAB》Problem 2.20

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  5. 《DSP using MATLAB》Problem 7.24

    又到清明时节,…… 注意:带阻滤波器不能用第2类线性相位滤波器实现,我们采用第1类,长度为基数,选M=61 代码: %% +++++++++++++++++++++++++++++++++++++++ ...

  6. 《DSP using MATLAB》Problem 7.23

    %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info a ...

  7. 《DSP using MATLAB》Problem 6.15

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  8. 《DSP using MATLAB》Problem 6.12

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  9. 《DSP using MATLAB》Problem 6.10

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

随机推荐

  1. laravel中的Auth认证:

    简介 Laravel 5.3 的 Auth 认证在 5.2 的基础上又有一些改变,本文说明如何在 Laravel 5.3 下做不同用户表的登录认证. Auth 认证原理简述 Laravel 的认证是使 ...

  2. Uboot USB模式(RK3288变砖头的解决办法)

    RK3288启动后有三种模式,可以分别进行操作. 第一种是normal也就是正常的启动模式.这个模式无法刷固件.一般板子通电就是这个模式 第二种是loader模式.就是刷固件模式.这个模式可以刷各种i ...

  3. frameset的固定放置模式,不能放入<form runat="server">中

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="admin_default.as ...

  4. java this的用法

    this 含义:代表当前对象 用法: 用于返回对象的引用 示例代码 public class Test { public Test f() { return this;//获取当前对象的引用 } pu ...

  5. RabbitMQ fanout类型的Exchange

    就目前来说,Exchange是与消息发送端有关的,因为它可以指定将消息发送到哪个或哪些队列中. 本篇文章介绍的fanout类型就是指定将消息群发到与Exchange绑定的所有队列中. fanout这个 ...

  6. Linux搭建Hadoop集群---Jdk配置

    三台虚拟机:master slave1 slave2 192.168.77.99 master 192.168.77.88 slave1 192.168.77.77 slave2   1.修改主机名: ...

  7. Cracking The Coding Interview 3.2

    //How would you design a stack which, in addition to push and pop, also has a function min which ret ...

  8. Linux输入子系统 : 按键驱动

    一.Linux input system框架: 1.由输入子系统核心层(input.c),驱动层(gpio_keys.c)和事件处理层(Event Handler)三部份组: 2.主要的三个结构体:i ...

  9. 7.2 C++模板类实例化

    参考:http://www.weixueyuan.net/view/6399.html 总结: array < int >表明用int类型来代替模板类中的类参数“T”,编译器会将模板类ar ...

  10. Appium Desktop 介绍及使用

    一.AppiumDesktop介绍 1.Appium-server的图形界面.可以设置选项.启动/停止服务器.查看日志等功能:且无须提前安装Node / NPM,因为Node运行时直接与Appium ...