# filter (Galois field)

1-D digital filter over Galois field

## Syntax

```y = filter(b,a,x) [y,zf] = filter(b,a,x) ```

## Description

`y = filter(b,a,x)` filters the data in the vector `x` with the filter described by numerator coefficient vector `b` and denominator coefficient vector `a`. The vectors `b`, `a`, and `x` must be Galois vectors in the same field. If `a(1)` is not equal to `1`, then `filter` normalizes the filter coefficients by `a(1)`. As a result, `a(1)` must be nonzero.

The filter is a Direct Form II Transposed implementation of the standard difference equation shown here:

```a(1)*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) ```

`[y,zf] = filter(b,a,x) ` returns the final conditions of the filter delays in the Galois vector `zf`. The length of the vector `zf` is `max(size(a),size(b))-1`.

## Examples

collapse all

When using the Galois 1-D digital filter function, the data is normalized by the first element of the denominator coefficient vector.

```a = gf([2 3 5 7],3); b = gf([1 3],3); x = gf(randi([0,7],10,1),3); filt_x = filter(b,a,x)```
``` filt_x = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal) Array elements = 6 6 3 4 7 4 2 2 0 5 ```

The first coefficient of the denominator coefficient vector, a(1) = 2. To confirm the function normalizes the data, manually normalize the filtered data. Use `isequal` to compare the outputs, we see they are equal.

`filt_x2 = a(1) * filter(b/a(1),a,x)`
``` filt_x2 = GF(2^3) array. Primitive polynomial = D^3+D+1 (11 decimal) Array elements = 6 6 3 4 7 4 2 2 0 5 ```
`isequal(filt_x,filt_x2)`
```ans = logical 1 ```