Digital Filter, Mathematics in Java,

I need your help, and thanks for reading my question! I am currently writing a java program that will use the Direket Form 2 Transposed Filter. I know that the function filter in Matlab will do it just fine, but I have to use Java. So who knows that you are implementing this Direkt Form 2 Transposed, this math function:

y (n) = b (1) * x (n) + b (2) * x (n-1) + ... + b (nb + 1) * x (n-nb) - a (2) * y (n-1) -... - a (na + 1) * y (n-na)

in any Programmm language? All that is required is, I hope, a point in the direction of movement, so I can understand it! Perhaps there is a C Lib that implements some of the matlab functions, just something.

So thanks for your time

yours elektro

Following actions:

I tried a couple of days to understand your function, but I could not.

This is a function from Matlab: filter

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/filter.html&http://www.google.de/search?hl=de&q = filter + matlab & btnG = Google-Suche & meta = & aq = f & oq =

All I know is that I use the following function in matlab:

newArray = filter (1, LPC_Faktor, OldArray)

All I have to do is implement the filter function.

So could you help again?

thanks

Elektro

+3
source share
2 answers

Regardless of which language you use, the transpose structure with direct form II is quite simple.

For example, in C, it could be something like:

float myFilter( float u)
{
  static float[nb] x = {0,0,0,...,0);  // initialize x
  static float[na] y = {0,0,0,...,0);  // initialize y
  static float b1 = ....;  // put b(1) here
  static float[nb] b = {...,...,...,...,...}; // put b(2) to b(nb+1) here
  static float[na] a = {...,...,...,...,...}; // put a(2) to a(na+1) values here

  // initialization
  float sum = 0;
  int i=0;

  // compute the value
  for(i=0;i<nb;i++)
    sum += b[i]*x[i];
  for(i=0;i<na;i++)
    sum -= a[i]*y[i];
  sum += b1*u;

  // prepare the values for the next time
  for(i=1;i<nb;i++)
    x[i] = x[i-1];
  x[0] = u;
  for(i=1;i<na;i++)
    y[i] = y[i-1];
  y[0] = sum;

  // return the value
  return sum;
}

, - .

Direct Form II - FIR- ( , , , ).

, (, ). .

EDIT: . ,

y(n) = b(1)x(n) + b(2)x(n-1) + ... + b(nb+1)x(n-nb) - a(2)y(n-1) - ... - a(na+1)*y(n-na)

- II, I. na + nb (n - ), II max (na, nb). , II,

e(n) = u(n) - a(1)*e(n-1) - a(2)*e(n-2) - ... - a(na)*e(n-na)
y(n) = b(1)*e(n-1) + b(2)*e(n-2) + ... + b(nb)*e(n-nb)

, .

+9

,

, :

filter(int ord, float *a, float *b, int np, float *x, float *y)
{
    int i,j;
    y[0]=b[0] * x[0];
    for (i=1;i<ord+1;i++)
    {
        y[i]=0.0;
        for (j=0;j<i+1;j++)
            y[i]=y[i]+b[j]*x[i-j];
        for (j=0;j<i;j++)
            y[i]=y[i]-a[j+1]*y[i-j-1];
    }
    /* end of initial part */
    for (i=ord+1;i<np+1;i++)
    {
        y[i]=0.0;
        for (j=0;j<ord+1;j++)
            y[i]=y[i]+b[j]*x[i-j];
        for (j=0;j<ord;j++)
            y[i]=y[i]-a[j+1]*y[i-j-1];
    }
} /* end of filter */
+2

Source: https://habr.com/ru/post/1711773/


All Articles