代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf(' *********************************************************** '); fprintf(' <DSP using MATLAB> Problem 6.22 '); banner(); %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %format long; format short; fprintf(' FIR filter DIRECT-form: '); h = [1, -4, 6.4, -5.12, 2.048, -0.32768]; b = h a = 1.0 fprintf(' Convert DIRECT-form to PARALLEL-form : '); [C, Bp, Ap] = dir2par(b, a) if size(C)==0 C = 0; end fprintf(' Convert DIRECT-form to CASCADE-form : '); [b0, Bc, Ac] = dir2cas(b, a) fprintf(' Convert TF-form to SOS-form : '); [sos, g] = tf2sos(b, a) fprintf(' Convert DIRECT-form to FREQUENCY-SAMPLE-form 1 : '); [Cfs, Bfs, Afs] = dir2fs(b) fprintf(' Convert DIRECT-form to FREQUENCY-SAMPLE-form 2 : '); r = 0.99; [Cfs_r, Bfs_r, Afs_r, rM] = dir2fs_r(b, r) % ---------------------------------------------------------- % NOTE: linear-phase can not use LATTICE-form % ---------------------------------------------------------- fprintf(' Convert DIRECT-form to All-Zero LATTICE-form : '); [Klc] = dir2latc(b) % ----------------------------------------- % 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 % ------------------------------------------- % +++++++++++++++++++++++++++++++++++++++++++++++++ % 5 1st-order section CASCADE-form % +++++++++++++++++++++++++++++++++++++++++++++++++ broots = roots(b) L = length(broots) B1 = ones(L, 2); fprintf(' Convert DIRECT-form to %d 1st-order section : ', L); for i = 1:1:L B1(i,:) = poly( broots(i) ); end B1 % +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % CASCADE-form of 1 1st-order section and 2 2nd-order section % +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fprintf(' Convert DIRECT-form to One 1st-order and Two 2nd-order section: '); B2 = poly( [broots(1), broots(2)] ) B3 = poly( [broots(3), broots(4)] ) B4 = poly( broots(5) ) % +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % CASCADE-form of 1 2nd-order section and 1 3rd-order section % +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ fprintf(' Convert DIRECT-form to One 2nd-order and One 3rd-order section: '); B5 = poly( [broots(1), broots(2)] ) B6 = poly( [broots(3), broots(4), broots(5)] )
运行结果:
直接形式的系数
串联形式系数
频率采样形式系数
格型Lattice形式系数
求出5个零点