MATLAB filter final conditions blow up

Discussion in 'Programmer's Corner' started by Alice, Jul 26, 2009.

  1. Alice

    Thread Starter New Member

    Mar 29, 2008

    I'm using the filter function in MATLAB to synthesize a speech signal block by block (I'm doing LPC analysis). There are 100 blocks and I have either a pulse train or noise as the input x_in to the filter function, then filter each block.

    I have a loop that runs for 1:99 times, and i use the final conditions of the filter after one block as the initial conditions for the next block using this code:

    zf = zeros(1,10)
    for ii = 1:99
    [y_in, zf] = filter(b,a,x_in,zf);

    My feedforward coefficients are a 1 by 11 vector, and my feedback coefficients are b = 1. x_in is the input vector to be filtered and z_f are final conditions of the filter, with all zeros the first time (as in the initial conditions for the very first block).

    Problem is that at after the 20th block, the final conditions suddenly become very large to the order of 10^39th power, and then get even larger until the zf vector just contains NAN (not a number). Up to that point, everything looks fine and sounds alright. Then the sound becomes very distorted.

    Any ideas why this may be happening and how I can fix it? I was thinking maybe I need to use the filtic function to get the initial conditions, or some other funtion to find the states?

    Please help!!!

    Thank you, Alice.