% IIR filter design example % % Bandstop Butterworth filter % Passband Ripple = 3 dB % Stopband Attenuation = 20 dB % Lower passband = 0 - 50 Hz % Upper passband = 450 - 500 Hz % Stopband = 200 - 300 Hz % Sampling frequency = 1 kHz Fs = 1000; % Sampling frequency FN = Fs/2; % Nyquist frequency Ap = 3; % Passband ripple As = 20; % Stopband attenuation wp = [50/FN, 450/FN]; % Normalized passband edge ws = [200/FN, 300/FN]; % Normalized stopband edge [N,wc] = buttord(wp, ws, Ap, As); [b,a] = butter(N,wp,'stop'); % Compute numerator & denominator coefficients [zz,pz,kz] = butter(N,wp,'stop'); % Compute zeros, poles, and gain subplot(2,1,1) [H,f] = freqz(b,a,512,Fs); % Compute frequency response plot(f, abs(H)) xlabel('Frequency (Hz)') ylabel('Magnitude Response') subplot(2,1,2) zplane(b,a) % Plot zeros and poles