% ----------------------------------------------------------------------------
% Example output from hpeq.m
%
% Chebyshev-2 lowpass shelving filter, boost
% ----------------------------------------------------------------------------
% Sophocles J. Orfanidis
% ECE Department, Rutgers University
% 94 Brett Road, Piscataway, NJ 08854-8058
%
% Email:   orfanidi@ece.rutgers.edu
% Date:    June 15, 2005
%
% Reference: Sophocles J. Orfanidis, "High-Order Digital Parametric Equalizer
%            Design," J. Audio Eng. Soc., vol.53, pp. 1026-1046, November 2005.
%
% Web Page: http://www.ece.rutgers.edu/~orfanidi/hpeq
%
% tested with MATLAB R11.1 and R14
% ----------------------------------------------------------------------------

clear all;

N = 4; fs = 40; f0 = 0; Df = 2; w0 = 0; Dw = 2*pi*Df/fs;
G0 = 0; G = 12; GB = 0.01; type = 2;

[B,A,Bh,Ah] = hpeq(N, G0, G, GB, w0, Dw, type)

f = linspace(0,20,1001); w = 2*pi*f/fs;

H = 20*log10(abs(fresp(B,A,w)));

[w1,w2] = bandedge(w0,Dw); f1 = fs * w1/2/pi; f2 = fs * w2/2/pi;

Gb = G-3; Dwb = bandwidth(N,G0,G,GB,Gb,Dw,type);                           % 3-dB width
[w1b,w2b] = bandedge(w0,Dwb); f1b = fs * w1b/2/pi; f2b = fs * w2b/2/pi;    % 3-dB frequencies

figure;
plot(f,H,'r-', [f1,f2,f1b,f2b],[GB,GB,Gb,Gb],'b.');
ylim([-8 14]); ytick(-6:3:12);
xlim([0,20]); xtick(0:2:20);
title('Chebyshev-2, LP Shelf, {\it N} = 4');
xlabel('{\it f}  (kHz)'); ylabel('dB');
grid;
B =

    1.0000         0         0         0         0
    1.1314   -2.0732    0.9950         0         0
    0.9620   -1.4925    0.5905         0         0


A =

    1.0000         0         0         0         0
    1.0000   -1.8678    0.8944         0         0
    1.0000   -1.6825    0.7126         0         0


Bh =

    1.0000         0         0
    1.1314   -2.0732    0.9950
    0.9620   -1.4925    0.5905


Ah =

    1.0000         0         0
    1.0000   -1.8678    0.8944
    1.0000   -1.6825    0.7126