TEAP (Toolbox for Emotion Analysis using Physiological Signals) doc
iirpeak.m
Go to the documentation of this file.
1 %> @file iirpeak.m
2 function [num, den] = iirpeak(Wo, BW, varargin)
3 %IIRPEAK Second-order IIR peaking (resonator) digital filter design.
4 % [NUM, DEN] = IIRPEAK(Wo, BW) designs a second-order resonator digital
5 % filter with the peak at frequency Wo and a bandwidth of BW at the 3 dB
6 % level. Wo must satisfy 0.0 < Wo < 1.0, with 1.0 corresponding to pi
7 % radians/sample.
8 %
9 % The bandwidth BW is related to the Q-factor of a filter by BW = Wo/Q.
10 %
11 % [NUM, DEN] = IIRPEAK(Wo, BW, Ab) designs a peaking filter with a bandwidth
12 % of BW at a level Ab in decibels. If not specified, Ab defaults to the
13 % 3 dB width (10*log10(2)).
14 %
15 % EXAMPLE:
16 % % Design a filter operating at a rate of 10 kHz that has a peak at
17 % % 1.75 kHz and a 3 dB width of 500 Hz.
18 % Fs = 10000; Wo = 1750/(Fs/2); BW = 500/(Fs/2);
19 % [b, a] = iirpeak(Wo, BW);
20 % fvtool(b, a);
21 %
22 % See also IIRNOTCH, IIRCOMB, FIRGR.
23 %
24 % Author(s): P. Pacheco
25 % Copyright 1999-2006 The MathWorks, Inc.
26 % $Revision: 1.1.4.4 $ $Date: 2007/12/14 14:34:01 $
27 %
28 % References:
29 % [1] Sophocles J. Orfanidis, Introduction To Signal Processing
30 % Prentice-Hall 1996.
31 
32 narginchk(2, 3);
33 
34 % Validate input arguments.
35 [Ab, msg] = notchpeakargchk(Wo, BW, varargin);
36 if ~isempty(msg)
37  error(generatemsgid('FilterErr'), msg);
38 end
39 
40 % Design a peaking filter.
41 [num, den] = secondorderPeak(Wo, BW, Ab);
42 
43 
44 
45 function [num, den] = secondorderPeak(Wo, BW, Ab)
46 % Design a 2nd order IIR peaking (resonator) digital filter.
47 
48 % Inputs are normalized by pi.
49 BW = BW*pi;
50 Wo = Wo*pi;
51 
52 Gb = 10^(-Ab/20);
53 beta = (Gb/sqrt(1-Gb.^2))*tan(BW/2);
54 gain = 1/(1+beta);
55 
56 num = (1-gain)*[1 0 -1];
57 den = [1 -2*gain*cos(Wo) (2*gain-1)];
58 
59 
60 % [EOF]
iirpeak
function iirpeak(in Wo, in BW, in varargin)
notchpeakargchk
function notchpeakargchk(in Wo, in BW, in opts)
secondorderPeak
function secondorderPeak(in Wo, in BW, in Ab)