Home > NoiseTools > nt_filter_peak.m

# nt_filter_peak

## PURPOSE

[B,A] = nt_filter_peak(Wo,Q) - second order resonator filter

## SYNOPSIS

function [B,A] = nt_filter_peak(Wo,Q)

## DESCRIPTION

    [B,A] = nt_filter_peak(Wo,Q) - second order resonator filter

     Wo: peak frequency (1 == nyquist)
     Q: quality factor

     NoiseTools

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- nt_narrowband_scan A=nt_narrowband_scan(x,freqs,sr,Q,plotflag) - scan for narrowband components using DSS

## SOURCE CODE

    0001 function [B,A] = nt_filter_peak(Wo,Q)
    0002 %[B,A] = nt_filter_peak(Wo,Q) - second order resonator filter
    0003 %
    0004 % Wo: peak frequency (1 == nyquist)
    0005 % Q: quality factor
    0006 %
    0007 % NoiseTools
    0008
    0009 if nargin<2; error('!'); end
    0010 if Wo>1; error('normalized centre frequency should be < 1'); end
    0011
    0012 BW=Wo/Q;
    0013
    0014 % frequencies are normalized by pi.
    0015 BW = BW*pi;
    0016 Wo = Wo*pi;
    0017
    0018 gain = 1/(1+tan(BW/2));
    0019 B  = (1-gain)*[1 0 -1];
    0020 A  = [1 -2*gain*cos(Wo) (2*gain-1)];
    0021
    0022 if ~nargout
    0023     figure(100);
    0024     freqz(B,A);
    0025     figure(101);
    0026     plot([-10:100],filter(B,A,[zeros(10,1);1;zeros(100,1)]));
    0027     xlabel('s / sr');
    0028 end
    0029