Butterworth Filter on Matlab

Discussion in 'Programmer's Corner' started by tquiva, Mar 15, 2011.

  1. tquiva

    Thread Starter Member

    Oct 19, 2010
    I'm currently having issues with my Matlab code for the following problem:

    1) The numeric Matlab command, [n,d]=butter(k,w0,'s'), will generate a vector of numerator coefficients, n, and the vector of denominator coefficients, d of a filter. The parameter k is a positive integer, usually less than 10; the parameter w0 is positive.

    (a) Use the command pzmap(n,d) to investigate the poles and zeroes of such a filter. Clearly discuss the effect of the parameters k and w0 on the poles and zeroes of the filter. Develop figures that clearly illustrate the behavior of the poles and zeroes of such a filter.

    My code is:

    Code ( (Unknown Language)):
    1. syms k w0;
    2. % k is a positive integer, less than 10
    3. k=0:0.1:9;
    4. % w0 is positive
    5. w0=0:0.1:inf;
    6. [n,d]=butter(k,w0,'s')
    When I run this, I get the error:

    ??? Maximum variable size allowed by the program is exceeded.

    So I tried changing inf to a number such as 0.1, but I get another error:

    ??? Error using ==> butter at 41
    The cutoff frequencies must be greater than zero.

    What am I doing wrong here?
    Could please help me?

    My many thanks in advance
  2. guitarguy12387

    Active Member

    Apr 10, 2008
    Look into the colon notation again. If you replace inf with 0.1, you get a range from 0 to .1 with a step size of .1. In other words, you are probably getting a vector with one element which is zero. You probably want a large number instead of inf (i.e. infinity...)
  3. Vahe


    Mar 3, 2011
    In the colon notation of Matlab if you write
    you will get an array from w0 from a to c with b as the increment.
    So if you write w0=0:0.1:1.0, you should get a vector from 0 to 1.0 in
    steps of 0.1. For reference, take a look at the document here