# fir_lsq

Version:

Designs a least-squares linear FIR filter.

## Syntax

y = fir_lsq(n, f, a)
y = fir_lsq(n, f, a, w)
y = fir_lsq(n, f, a, option)
y = fir_lsq(n, f, a, w, option)
Legacy name: firls

## n

Filter order. n is a nonnegative integer.

## f

Normalized frequencies at which you want to take samples. The size of f must be even. f is a vector.

## a

Specifies the amplitudes at each of the f frequencies. a is a vector of the same size as f.

## w

Weight. w is a vector that is half the length of f.

## option

Odd-symmetry filter to design. option is a string that accepts the following values:

Name Description
'differentiator'

Differentiator filter.

'Hilbert'

Hilbert filter.

## y

Filter coefficients of order n. y is a real vector.

## Special Case

If f = [0.1, 0.2, 0.3, 0.4] and a = [1, 1, 0, 0], MathScript ignores the interval [0.2, 0.3] and attempts to implement a filter whose amplitude is 1 in [0.1, 0.2] and 0 in [0.3, 0.4].

N = 11;
F = [0.1, 0.2, 0.3, 0.4];
A = [1, 1, 0, 0];
Y = fir_lsq(N, F, A)

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices