Simple MATLAB code for Butterworth filter

Simple code for Butterworth filter using MATLAB

clc;
close all;
clear all;

rp=0.2;             %input('enter the passband ripple:');
rs= 0.8;           %input('enter the stopband ripple:');
wp= 800;           %input('enter the passband freq:');
ws=2400;           %input('enter the stopband freq:');
fs=10000;          %input('enter the sampling freq:');

w1=2*wp/fs;
w2=2*ws/fs;

[n,wn]=buttord(w1,w2,rp,rs);   

[b,a]=butter(n,wn);

[h,om]=freqz(b,a);

figure;
plot(om,h);
title('IIR Filter magnitude Response');
ylabel('Gain');
xlabel(' frequency');

BUTTERWORTH


No comments