project

profilemaulika
cascadeIIRNotch.m

function [a,b] = cascadeIIRNotch(notchFrequencies, alpha, beta) % y = IIRNotchFilter(soundfilename, zeroCoefficients, poleCoefficients, alpha) % % Computes the coefficients for a cascaded IIR digital notch filter. Each % cascaded IIR notch filter is a second order filter. Thus, for each notch % frequency specified a second order filter is added to the cascaded system. % % notchFrequencies A vector specifying the digital frequencies to be notched. % alpha The magnitude of the poles % beta The magnitude of the zeros % % a Coefficients of the numerator polynomial % b Coefficient of the denominator polynomial % % % Cascaded Digital Notch Filter Implementation % Dr. Ratliff % ECE505 %Calculate locations of each pole and zero, noting that each pole-zero %also has a matching complex conjugates. All I am doing here is using the %convolution command to multiply out the transfer function polynomials to %obtain the coefficients. w = notchFrequencies; for k=1:length(w) if(k==1) Z = conv([ 1 -beta*exp(1i*w(k))], [ 1 -beta*exp(-1i*w(k))]); P = conv([ 1 -alpha*exp(1i*w(k))], [ 1 -alpha*exp(-1i*w(k))]); else Z = conv(Z, [ 1 -beta*exp(1i*w(k))]); Z = conv(Z, [ 1 -beta*exp(-1i*w(k))]); P = conv(P, [ 1 -alpha*exp(1i*w(k))]); P = conv(P, [ 1 -alpha*exp(-1i*w(k))]); end end %Take the real part of the coefficients for use in the difference equation and display them a = real(Z); b = real(P); fprintf('Cascaded Notch Filter Numerator (Zero) Coefficients\n'); disp(a); fprintf('Cascaded Notch Filter Denominator (Pole) Coefficients\n'); disp(b);