+ Post New Thread
Results 1 to 6 of 6
  1. #1
    Member level 1
    Points: 497, Level: 4

    Join Date
    Jan 2014
    Location
    kakinada
    Posts
    36
    Helped
    0 / 0
    Points
    497
    Level
    4

    iir filter design in matlab

    hi
    i had written a code in matlab for a iir filter with following specs
    wp=[200 315] and sampling frequency 16600
    but i need to deside the other specs i.e. stopband freqyencies and ripple and attenuations
    but the filter characteristics are not producing due to high sampling frequencies.
    the sampling frequency must be high because this is a bank of filters with range of 200 to 7500
    please help me to get the filter characteristics

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 260,203, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,441
    Helped
    13826 / 13826
    Points
    260,203
    Level
    100

    Re: iir filter design in matlab

    but the filter characteristics are not producing due to high sampling frequencies
    I don't understand what you exactly mean with this statement.

    An IIR filter with nomalized passband corner frequencies [0.012 0.019] can be made. You get of course a high dynamic range for the filter cofficients, resulting in respectively high word length of a fixed point implementation. I presume the Matlab filter design functions will just calculate the parameters. So what's your problem?



    •   AltAdvertisement

        
       

  3. #3
    Member level 1
    Points: 497, Level: 4

    Join Date
    Jan 2014
    Location
    kakinada
    Posts
    36
    Helped
    0 / 0
    Points
    497
    Level
    4

    Re: iir filter design in matlab

    Quote Originally Posted by FvM View Post
    I don't understand what you exactly mean with this statement.

    An IIR filter with nomalized passband corner frequencies [0.012 0.019] can be made. You get of course a high dynamic range for the filter cofficients, resulting in respectively high word length of a fixed point implementation. I presume the Matlab filter design functions will just calculate the parameters. So what's your problem?
    Code:
    close all; clear all; clc;
     
    % Generate input signal
    fsamp = 16600; % (Hz)
    dt = 1/fsamp; % (secs)
    t = 0:dt:0.2;
    fsine1 = 100; % (in passband: should remain in filter output)
    a=10;
    % am=20*log(a);
    %fsine2 = 450; % (in stopband: should be removed by filter)
    in = a*sin(2*pi*fsine1*t); 
    %+ 10*sin(2*pi*fsine2*t);
     
    % Plot input signal
    figure(1);
    plot(t, in);
    title('Input');
    xlabel('Time (secs)');
    ylabel('Amplitude');
    grid on;
     
    % Design filter
    wp = [200 315]; % Passband corner frequency
    ws = [180 346.5]; % Stopband corner frequency
    rp = 1;   % Passband ripple (dB)
    rs = 80;  % Stopband attenuation (dB)
    w1 = 2*wp/fsamp;
    w2 = 2*ws/fsamp;
    [N,wn] = ellipord(w1,w2,rp,rs)
    [b,a] = ellip(N,rp,rs,wn);
     
    % Plot filter frequency response
    [H,W] = freqz(b,a,fsamp);
    mag = 20*log(abs(H));
    figure(2);
    plot(fsamp*W/(2*pi), mag);
    title('Frequency Response');
    xlabel('Frequency (Hz)');
    ylabel('(dB)');
    axis tight;
    grid on;
     
    % Apply filter and plot output
    out = filter(b, a,in);
    figure(3);
    plot(t, out);
    xlabel('Time (secs)');
    ylabel('Amplitude');
    grid on;
    just see the response of the code we are not getting the filter characteristics due to high sampling frequency
    i don understand what is the relation with sampling frequencies
    and i want to know what are the limitations of normalized frequencies if any exists



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 260,203, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,441
    Helped
    13826 / 13826
    Points
    260,203
    Level
    100

    Re: iir filter design in matlab

    I see the problem.

    It's nature (numerical instabilities with [a,b] filter description) and possible solutions (use [z,p,k] description) are discussed in the Matlab online help under ellip function limitations.


    1 members found this post helpful.

  5. #5
    Member level 1
    Points: 497, Level: 4

    Join Date
    Jan 2014
    Location
    kakinada
    Posts
    36
    Helped
    0 / 0
    Points
    497
    Level
    4

    Re: iir filter design in matlab

    how to filter the input with sos and g
    since we cant give the input to the filter without filter coefficients



    •   AltAdvertisement

        
       

  6. #6
    Newbie level 5
    Points: 80, Level: 1

    Join Date
    Feb 2015
    Posts
    9
    Helped
    4 / 4
    Points
    80
    Level
    1

    Re: iir filter design in matlab

    Quote Originally Posted by lakshmikalyani View Post
    how to filter the input with sos and g
    since we cant give the input to the filter without filter coefficients
    You need to read a little bit in the matlab help sections for this information.

    sos format means second order sections. So for example, if you are exporting the sos parameters from fdatool, it gives an sos matrix where each line corresponds to a set of 2nd order filter coefficients.

    You can implement this as a cascade of second order sections, or you can use sos2tf to convert to an overall transfer function. And then use the filter function to find the output. Also see sosfilt for finding output straight from sos matrix.

    Your filter requirements are quite stringent. You should definitely be looking at the necessary dynamic range (word length) and the sensitivity of coefficients. Cascading second order sections to realize your filter reduces this sensitivity.

    See matlab help section in signal processing toolbox >> analog and digital filters >> digital filter implementation.


    2 members found this post helpful.

--[[ ]]--