## Filter Coefficients for ButterWorth Low pass filter

### Crystal (view profile)

on 29 Apr 2013
`     I am new to Digital Filter. I want to know filter Coefficients calculation formula manually for second order Butter Worth Low pass Filter.`
`    And also i want to know sampling and cutoff frequency apply for the input signal. But i know fs > 2fmax for sampling is it correct or not.`

## Products

No products are associated with this question.

### Jan Simon (view profile)

Answer by Jan Simon

### Jan Simon (view profile)

on 29 Apr 2013
Edited by Jan Simon

### Jan Simon (view profile)

on 29 Apr 2013

Do you really need the "filter coefficients calculations formula", or would is be satisfying already to call the function butter() to determine the coefficients?

The sampling frequency depends on your data, and therefore this cannot be answered by the forum, but by yourself only. The cut-off frequency depends on the wanted frequency spectrum, such that it is impossible for us to guess it. The cutoff frequency cannot be higher than the half frame rate - this is more or less obvious e.g. trying to filter a signal at 1kHz must fail, when it has been recorded at 1Hz only.

[EDITED] A boiled down 2nd order Butterworth filter algorithm:

```function [B, A] = myButter2ndOrder(W)
```
```V  = tan(W * 1.5707963267948966);
Sg = V ^ 2;
Sp = V * [-1-1i, -1+1i] / sqrt(2);
```
```% Bilinear transform:
P = (1 + Sp) ./ (1 - Sp);
G = real(Sg / prod(1 - Sp));
```
```% From Zeros, Poles and Gain to numerator and denominator:
B = G * [1, 2, 1];
A = real(poly(P));
```

W is the cut-off frequency in the range 0 < W < 1, so it is relative to the half sample frequency.

Crystal

### Crystal (view profile)

on 29 Apr 2013

Thanks for your response,

`         I am not need a butter() function. I need only the filter coefficient formula for second order low pass butter worth digital filter.`

This is the data for input. From this input please specify the condition for sampling and cutoff frequency

if true % 0.00E+00 9.81E-03 9.81E-03 9.81E-03 9.81E-03 9.81E-03 9.81E-03 9.81E-03 9.79E-03 9.76E-03 9.67E-03 9.51E-03 9.26E-03 8.86E-03 8.35E-03 7.75E-03 7.05E-03 6.27E-03 5.38E-03 4.45E-03 3.54E-03 2.63E-03 1.77E-03 1.23E-03 1.42E-03 2.13E-03 2.99E-03 3.94E-03 4.87E-03 5.73E-03 6.52E-03 7.27E-03 7.92E-03 8.42E-03 8.80E-03 9.06E-03 9.21E-03 9.26E-03 9.21E-03 9.10E-03 8.94E-03 8.75E-03 8.56E-03 8.35E-03 8.14E-03 7.92E-03 7.69E-03 7.46E-03 7.22E-03 6.96E-03 6.69E-03 6.42E-03 6.14E-03 5.86E-03 5.57E-03 5.29E-03 5.03E-03 4.77E-03 4.50E-03 4.22E-03 3.95E-03 3.66E-03 3.34E-03 2.99E-03 2.61E-03 2.24E-03 1.89E-03 1.59E-03 1.43E-03 1.46E-03 1.65E-03 1.95E-03 2.31E-03 2.69E-03 3.05E-03 3.40E-03 3.74E-03 4.05E-03 4.47E-03 4.79E-03 4.99E-03 5.13E-03 5.19E-03 5.16E-03 5.06E-03 4.91E-03 4.70E-03 4.45E-03 4.15E-03 3.79E-03 3.37E-03 2.91E-03 2.46E-03 2.05E-03 1.72E-03 1.56E-03 1.62E-03 1.87E-03 2.23E-03 2.68E-03 3.15E-03 3.58E-03 3.99E-03 4.39E-03 4.76E-03 5.09E-03 5.39E-03 5.65E-03 5.89E-03 6.09E-03 6.24E-03 6.35E-03 6.44E-03 6.50E-03 6.52E-03 6.51E-03 6.47E-03 6.39E-03 6.26E-03 6.11E-03 5.92E-03 5.69E-03 5.42E-03 5.12E-03 4.79E-03 4.43E-03 4.03E-03 3.62E-03 3.24E-03 2.89E-03 2.57E-03 2.34E-03 2.22E-03 2.21E-03 2.29E-03 2.46E-03 2.67E-03 2.89E-03 3.11E-03 3.32E-03 3.51E-03 3.66E-03 3.78E-03 3.88E-03 3.94E-03 3.98E-03 4.00E-03 3.99E-03 3.97E-03 3.94E-03 3.89E-03 3.84E-03 3.78E-03 3.71E-03 3.64E-03 3.56E-03 3.47E-03 3.36E-03 3.24E-03 3.11E-03 2.98E-03 2.86E-03 2.75E-03 2.70E-03 2.70E-03 2.80E-03 2.99E-03 3.27E-03 3.63E-03 4.07E-03 4.56E-03 5.06E-03 5.58E-03 6.12E-03 6.66E-03 7.15E-03 7.61E-03 8.03E-03 8.42E-03 8.75E-03 9.00E-03 9.20E-03 9.34E-03 9.41E-03 9.42E-03 9.37E-03 9.27E-03 9.12E-03 8.94E-03 8.72E-03 8.47E-03 8.19E-03 7.91E-03 7.62E-03 7.32E-03 7.00E-03 6.69E-03 6.39E-03 6.10E-03 5.81E-03 5.53E-03 5.29E-03 5.06E-03 4.85E-03 4.65E-03 4.49E-03 4.34E-03 4.21E-03 4.10E-03 4.01E-03 3.94E-03 3.87E-03 3.83E-03 3.80E-03 3.78E-03 3.77E-03 3.78E-03 3.80E-03 3.83E-03 3.87E-03 3.93E-03 4.01E-03 4.09E-03 4.19E-03 4.32E-03 4.45E-03 4.61E-03 4.78E-03 4.98E-03 5.21E-03 5.45E-03 5.72E-03 6.02E-03 6.33E-03 6.61E-03 6.89E-03 7.21E-03 7.57E-03 7.95E-03 8.31E-03 8.65E-03 8.95E-03 9.20E-03 9.41E-03 9.60E-03 9.84E-03 1.01E-02 1.04E-02 1.07E-02 1.07E-02 1.06E-02 1.04E-02 1.01E-02 9.73E-03 9.42E-03 9.13E-03 8.81E-03 8.41E-03 7.93E-03 7.43E-03 6.89E-03 6.32E-03 5.76E-03 5.22E-03 4.65E-03 4.02E-03 3.40E-03 2.89E-03 2.50E-03 2.30E-03 2.26E-03 2.33E-03 2.46E-03 2.63E-03 2.79E-03 2.94E-03 3.04E-03 3.09E-03 3.11E-03 3.12E-03 3.11E-03 3.09E-03 3.04E-03 2.94E-03 2.78E-03 2.56E-03 2.30E-03 2.05E-03 1.82E-03 1.68E-03 1.65E-03 1.75E-03 1.95E-03 2.22E-03 2.52E-03 2.82E-03 3.14E-03 3.46E-03 3.81E-03 4.19E-03 4.58E-03 5.00E-03 5.44E-03 5.85E-03 6.24E-03 6.61E-03 6.97E-03 7.32E-03 7.66E-03 8.01E-03 8.36E-03 8.72E-03 9.06E-03 9.37E-03 9.63E-03 9.83E-03 9.94E-03 9.94E-03 9.82E-03 9.58E-03 9.22E-03 8.76E-03 8.20E-03 7.57E-03 6.94E-03 6.30E-03 5.64E-03 4.95E-03 4.23E-03 3.48E-03 2.65E-03 1.79E-03 9.85E-04 8.03E-04 1.47E-03 2.35E-03 3.19E-03 3.90E-03 4.50E-03 4.93E-03 5.21E-03 5.35E-03 5.37E-03 5.30E-03 5.16E-03 4.97E-03 4.75E-03 4.49E-03 4.20E-03 3.91E-03 3.63E-03 3.35E-03 3.09E-03 2.86E-03 2.67E-03 2.50E-03 2.36E-03 2.33E-03 2.27E-03 2.37E-03 2.65E-03 3.19E-03 4.04E-03 5.19E-03 6.65E-03 8.42E-03 1.06E-02 1.32E-02 1.61E-02 1.93E-02 2.26E-02 2.57E-02 2.85E-02 3.10E-02 3.32E-02 3.51E-02 3.66E-02 3.77E-02 3.85E-02 3.88E-02 3.87E-02 3.81E-02 3.70E-02 3.53E-02 3.29E-02 2.97E-02 2.57E-02 2.09E-02 1.56E-02 1.01E-02 6.32E-03 7.45E-03 1.17E-02 1.64E-02 2.08E-02 2.47E-02 2.80E-02 3.11E-02 3.39E-02 3.65E-02 3.89E-02 4.11E-02 4.30E-02 4.45E-02 4.54E-02 4.55E-02 4.45E-02 4.26E-02 3.95E-02 3.55E-02 3.08E-02 2.53E-02 1.98E-02 1.50E-02 1.15E-02 1.06E-02 1.27E-02 1.64E-02 2.07E-02 2.53E-02 3.01E-02 3.50E-02 3.99E-02 4.51E-02 5.04E-02 5.56E-02 6.02E-02 6.46E-02 6.86E-02 7.19E-02 7.46E-02 7.69E-02 7.85E-02 7.98E-02 8.09E-02 8.18E-02 8.27E-02 8.36E-02 8.45E-02 8.55E-02 8.64E-02 8.73E-02 8.79E-02 8.83E-02 8.83E-02 8.80E-02 8.75E-02 8.68E-02 8.61E-02 8.55E-02 8.50E-02 8.48E-02 8.52E-02 8.60E-02 8.73E-02 8.91E-02 9.12E-02 9.38E-02 9.66E-02 9.96E-02 1.03E-01 1.07E-01 1.10E-01 1.14E-01 1.19E-01 1.24E-01 1.29E-01 1.37E-01 1.41E-01 1.48E-01 1.55E-01 1.62E-01 1.68E-01 2.04E-01 2.06E-01 2.81E-01 2.43E-01 3.23E-01 3.31E-01 3.54E-01 3.67E-01 3.63E-01 3.46E-01 3.34E-01 3.25E-01 2.61E-01 3.17E-01 2.97E-01 3.01E-01 2.85E-01 3.03E-01 3.19E-01 2.77E-01 2.66E-01 2.55E-01 2.60E-01 2.82E-01 3.11E-01 3.16E-01 3.10E-01 3.13E-01 3.05E-01 2.68E-01 2.67E-01 2.99E-01 3.16E-01 3.07E-01 2.78E-01 2.82E-01 2.86E-01 2.72E-01 2.36E-01 1.85E-01 1.51E-01 1.49E-01 1.64E-01 1.81E-01 1.64E-01 2.28E-01 2.49E-01 2.86E-01 3.13E-01 3.33E-01 3.31E-01 3.50E-01 3.86E-01 4.15E-01 4.26E-01 4.59E-01 4.70E-01 4.92E-01 5.23E-01 5.29E-01 4.71E-01 4.70E-01 4.86E-01 4.86E-01 4.52E-01 4.14E-01 4.17E-01 3.97E-01 4.39E-01 4.23E-01 4.34E-01 4.31E-01 4.38E-01 4.36E-01 4.17E-01 3.83E-01 3.29E-01 2.98E-01 2.54E-01 2.21E-01 2.32E-01 2.16E-01 2.22E-01 2.34E-01 2.58E-01 2.70E-01 2.96E-01 3.43E-01 3.64E-01 3.83E-01 3.94E-01 4.02E-01 4.08E-01 3.72E-01 3.32E-01 3.07E-01 2.93E-01 3.04E-01 3.23E-01 3.47E-01 3.34E-01 3.31E-01 3.06E-01 2.96E-01 2.85E-01 2.86E-01 2.79E-01 2.96E-01 3.15E-01 3.41E-01 3.54E-01 3.92E-01 4.17E-01 4.41E-01 4.54E-01 4.68E-01 4.80E-01 4.85E-01 4.92E-01 4.85E-01 5.01E-01 4.98E-01 5.04E-01 5.32E-01 5.37E-01 5.72E-01 5.88E-01 5.97E-01 6.05E-01 6.30E-01 6.15E-01 6.31E-01 6.47E-01 6.32E-01 6.34E-01 6.27E-01 6.32E-01 6.47E-01 6.56E-01 6.78E-01 6.58E-01 6.47E-01 6.27E-01 6.06E-01 5.79E-01 5.67E-01 5.62E-01 5.69E-01 5.85E-01 6.00E-01 6.18E-01 6.31E-01 6.37E-01 6.30E-01 6.18E-01 6.07E-01 5.91E-01 5.82E-01 5.64E-01 5.75E-01 5.87E-01 6.00E-01 6.14E-01 6.43E-01 6.74E-01 7.08E-01 7.21E-01 7.25E-01 7.14E-01 7.18E-01 7.21E-01 7.13E-01 7.07E-01 7.08E-01 7.18E-01 7.17E-01 7.31E-01 7.30E-01 7.37E-01 7.26E-01 7.28E-01 7.32E-01 7.38E-01 7.49E-01 7.69E-01 7.66E-01 7.69E-01 7.69E-01 7.72E-01 7.92E-01 7.98E-01 8.17E-01 8.30E-01 8.19E-01 8.11E-01 8.03E-01 7.94E-01 7.84E-01 7.73E-01 7.57E-01 7.48E-01 7.51E-01 7.62E-01 7.80E-01 8.13E-01 8.26E-01 8.34E-01 8.37E-01 8.21E-01 7.88E-01 7.64E-01 7.50E-01 7.45E-01 7.45E-01 7.46E-01 7.43E-01 7.45E-01 7.33E-01 7.34E-01 7.35E-01 7.33E-01 7.34E-01 7.39E-01 7.47E-01 7.59E-01 7.73E-01 7.85E-01 7.93E-01 7.93E-01 7.80E-01 7.69E-01 7.63E-01 7.64E-01 7.72E-01 7.79E-01 7.78E-01 7.68E-01 7.51E-01 7.32E-01 7.20E-01 7.19E-01 7.29E-01 7.43E-01 7.60E-01 7.75E-01 7.82E-01 7.87E-01 7.90E-01 7.94E-01 8.01E-01 8.08E-01 8.13E-01 8.01E-01 7.91E-01 7.83E-01 7.76E-01 7.68E-01 7.63E-01 7.65E-01 7.73E-01 7.89E-01 8.14E-01 8.40E-01 8.56E-01 8.55E-01 8.37E-01 8.06E-01 7.69E-01 7.34E-01 7.08E-01 6.96E-01 6.98E-01 7.07E-01 7.21E-01 7.38E-01 7.53E-01 7.60E-01 7.64E-01 7.60E-01 7.50E-01 7.41E-01 7.34E-01 7.31E-01 7.36E-01 7.48E-01 7.60E-01 7.65E-01 7.65E-01 7.43E-01 7.32E-01 7.32E-01 7.40E-01 7.48E-01 7.46E-01 7.30E-01 7.05E-01 6.79E-01 6.57E-01 6.45E-01 6.45E-01 6.53E-01 6.63E-01 6.71E-01 6.78E-01 6.81E-01 6.81E-01 6.77E-01 6.74E-01 6.70E-01 6.61E-01 6.50E-01 6.38E-01 6.25E-01 6.16E-01 6.17E-01 6.28E-01 6.39E-01 6.44E-01 6.41E-01 6.38E-01 6.41E-01 6.49E-01 6.63E-01 6.71E-01 6.66E-01 6.48E-01 6.24E-01 5.97E-01 5.77E-01 5.68E-01 5.68E-01 5.79E-01 5.97E-01 6.14E-01 6.23E-01 6.29E-01 6.32E-01 6.34E-01 6.36E-01 6.33E-01 6.23E-01 6.08E-01 5.97E-01 5.95E-01 6.06E-01 6.24E-01 6.46E-01 6.63E-01 6.70E-01 6.66E-01 6.58E-01 6.50E-01 6.47E-01 6.45E-01 6.40E-01 6.19E-01 5.91E-01 5.61E-01 5.37E-01 5.30E-01 5.40E-01 5.61E-01 5.83E-01 5.97E-01 6.00E-01 5.93E-01 5.86E-01 5.83E-01 5.83E-01 5.79E-01 5.72E-01 5.76E-01 5.67E-01 5.52E-01 5.36E-01 5.23E-01 5.14E-01 5.08E-01 5.05E-01 5.05E-01 5.07E-01 5.08E-01 5.11E-01 5.19E-01 5.30E-01 5.41E-01 5.48E-01 5.50E-01 5.48E-01 5.43E-01 5.33E-01 5.18E-01 5.03E-01 4.88E-01 4.75E-01 4.62E-01 4.55E-01 4.54E-01 4.55E-01 4.57E-01 4.63E-01 4.74E-01 4.74E-01 4.78E-01 4.75E-01 4.72E-01 4.70E-01 4.70E-01 4.73E-01 4.75E-01 4.64E-01 4.50E-01 4.39E-01 4.33E-01 4.31E-01 4.33E-01 4.34E-01 4.35E-01 4.37E-01 4.24E-01 4.16E-01 4.11E-01 4.08E-01 4.09E-01 4.10E-01 4.08E-01 4.01E-01 3.91E-01 3.81E-01 3.74E-01 3.69E-01 3.64E-01 3.59E-01 3.53E-01 3.48E-01 3.44E-01 3.41E-01 3.40E-01 3.40E-01 3.40E-01 3.37E-01 3.33E-01 3.33E-01 3.27E-01 3.26E-01 3.26E-01 3.25E-01 3.25E-01 3.23E-01 3.20E-01 3.16E-01 3.15E-01 3.14E-01 3.15E-01 3.12E-01 3.17E-01 3.00E-01 2.95E-01 2.95E-01 2.99E-01 3.02E-01 3.06E-01 3.07E-01 3.05E-01 2.91E-01 2.74E-01 2.50E-01 2.27E-01 2.17E-01 2.19E-01 2.32E-01 2.60E-01 3.01E-01 3.46E-01 3.75E-01 3.88E-01 3.78E-01 3.43E-01 2.94E-01 2.48E-01 2.12E-01 1.85E-01 1.67E-01 1.68E-01 1.82E-01 2.03E-01 2.29E-01 2.53E-01 2.99E-01 3.28E-01 3.49E-01 3.52E-01 3.33E-01 3.01E-01 2.64E-01 2.29E-01 2.00E-01 1.81E-01 1.78E-01 1.93E-01 2.13E-01 2.56E-01 2.91E-01 3.16E-01 3.27E-01 3.21E-01 3.10E-01 2.93E-01 2.75E-01 2.55E-01 2.36E-01 2.19E-01 2.08E-01 2.03E-01 1.97E-01 1.91E-01 1.81E-01 1.66E-01 1.75E-01 1.79E-01 1.89E-01 2.02E-01 2.22E-01 2.47E-01 2.66E-01 2.67E-01 2.47E-01 2.13E-01 1.73E-01 1.43E-01 1.28E-01 1.25E-01 1.27E-01 1.30E-01 1.33E-01 1.42E-01 1.57E-01 1.72E-01 1.78E-01 1.82E-01 1.75E-01 1.84E-01 1.64E-01 1.42E-01 1.19E-01 1.03E-01 1.02E-01 1.32E-01 1.51E-01 1.70E-01 1.89E-01 2.03E-01 2.15E-01 2.29E-01 2.21E-01 2.05E-01 1.79E-01 1.49E-01 1.21E-01 9.97E-02 8.97E-02 9.72E-02 1.21E-01 1.54E-01 1.89E-01 2.20E-01 2.44E-01 2.49E-01 2.38E-01 2.10E-01 1.77E-01 1.46E-01 1.20E-01 9.99E-02 7.98E-02 7.04E-02 8.95E-02 1.31E-01 1.67E-01 2.03E-01 2.31E-01 2.42E-01 2.33E-01 2.03E-01 1.61E-01 1.12E-01 6.91E-02 4.75E-02 5.52E-02 7.05E-02 7.43E-02 7.25E-02 8.30E-02 1.06E-01 1.28E-01 1.42E-01 1.48E-01 1.45E-01 1.29E-01 9.94E-02 6.83E-02 4.81E-02 3.66E-02 2.75E-02 2.56E-02 3.82E-02 5.94E-02 8.39E-02 1.06E-01 1.21E-01 1.29E-01 1.30E-01 1.23E-01 1.08E-01 8.65E-02 6.51E-02 5.03E-02 4.41E-02 4.71E-02 5.98E-02 7.91E-02 9.92E-02 1.13E-01 1.16E-01 1.09E-01 9.64E-02 7.92E-02 6.13E-02 end this is the data for input signal.

Jan Simon

### Jan Simon (view profile)

on 29 Apr 2013

Please note, that the value of the signal does not allow to determine the filter coefficients. Neither sampling nor cut-off frequency can be determined based on the values of the signal. The sampling frequency must be provided separately and the cut-off frequency depends on your needs and it is impossible to guess them.

I cannot understand, why you want the formula to calculate the filter parameters, but the implementation in the function butter() does not satisfy you. This function contains an efficient and stable implementation, so what do you want instead?

Jan Simon

### Jan Simon (view profile)

on 30 Apr 2013

@Crystal: Sorry, I'm not going to post more answers in this thread. It is a waste of my time if you offer the specifications of your question part by part only. If you want to know, what happens inside butter(), simply open this function in the editor and read it. Good luck.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.