Skip to content

Instantly share code, notes, and snippets.

@Arunprakash-A
Last active May 26, 2021 17:10
Show Gist options
  • Select an option

  • Save Arunprakash-A/b4a762425fc9aeaec3fbab8569f116dc to your computer and use it in GitHub Desktop.

Select an option

Save Arunprakash-A/b4a762425fc9aeaec3fbab8569f116dc to your computer and use it in GitHub Desktop.

Revisions

  1. Arunprakash-A revised this gist Sep 6, 2018. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion IIR_analog_Butter.m
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    clc;
    clear all;
    close all;

    % Specifications
    Wp=2*pi*100; % Passband cutoff in rad/s
    Ws=2*pi*200; % stopband cutoff in rad/s
    Fs=8000; % Sampling Frequency
    @@ -13,11 +13,15 @@
    ws=Ws*Ts; % Digital stopband cutoff freq in rad/sample
    ap=3; % passband attenuation in dB
    as=30; % stopband Attenuation in dB

    % Design Starts from here
    [N,wc]=buttord(wp,ws,ap,as,'s'); % returns order and Wc
    [zeros,poles,kf]=buttap(N); % returns Pole locations and gain
    [ztn,ptn]=zp2tf(zeros,poles,kf); % cooefficients of denominator polynomial
    [normalized_zeros,normalized_poles]=lp2lp(ztn,ptn,wc); % Denormalize
    [mag,freq]=freqs(normalized_zeros,normalized_poles,500); % plot magnitude response

    %plot the magnitude response
    plot((freq/(2*pi))*Fs,20*log10(abs(mag))); % ./ 2*pi to see an integer of freq in Hz
    axis([0 400 -50 0 ])
    title('Analog Butterworth Filter');
  2. Arunprakash-A created this gist Sep 6, 2018.
    26 changes: 26 additions & 0 deletions IIR_analog_Butter.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    % ************IIR Analog Butterworth Filter Design ******************%
    %************* Author : Arun Prakash A ******************************%

    clc;
    clear all;
    close all;

    Wp=2*pi*100; % Passband cutoff in rad/s
    Ws=2*pi*200; % stopband cutoff in rad/s
    Fs=8000; % Sampling Frequency
    Ts=1/Fs;
    wp=Wp*Ts; % Digital passband cutoff freq in rad/sample
    ws=Ws*Ts; % Digital stopband cutoff freq in rad/sample
    ap=3; % passband attenuation in dB
    as=30; % stopband Attenuation in dB
    [N,wc]=buttord(wp,ws,ap,as,'s'); % returns order and Wc
    [zeros,poles,kf]=buttap(N); % returns Pole locations and gain
    [ztn,ptn]=zp2tf(zeros,poles,kf); % cooefficients of denominator polynomial
    [normalized_zeros,normalized_poles]=lp2lp(ztn,ptn,wc); % Denormalize
    [mag,freq]=freqs(normalized_zeros,normalized_poles,500); % plot magnitude response
    plot((freq/(2*pi))*Fs,20*log10(abs(mag))); % ./ 2*pi to see an integer of freq in Hz
    axis([0 400 -50 0 ])
    title('Analog Butterworth Filter');
    xlabel('Frequency in Hz');
    ylabel('Magnitude in dB');
    grid on