I hope to design 1st order highpass filter from transfer function. In the example of 1st order lowpass filter, I first get the coefficients of numerator and denominator in the variable 'b' and 'a'. In case of first order filer,

b = 1/tau;
a = [1, 1/tau];
h = freqs(b, a, w) % LPF
[digital_b, digial_a] = bilinear(b, a, fs) % Analog to Digital transformation.

The order is like above. First, we obtain the coefficients of the transfer function and then make LPF by the 'freq' function in MATLAB. After that, I can convert the analog filter to a digital filter by using the 'bilinear' function.

However, in case of HPF, I cannot transform it using the 'bilinear' function. When I run the 'bilinear' function in MATLAB for 1st order HPF, it gives the following error

Numerator cannot be higher order than denominator.

I used the code below to make digital HPF.

b = [1, 1/tau];
a = 1;
h = freqs(b, a, w) % LPF
[digital_b, digial_a] = bilinear(b, a, fs) % Analog to Digital transformation.

What is the problem? and how should I design HPF on MATLAB?

• by this method, you're not designing HPF filter, by this you are designing inverse filter of your LPF which has gain one for low frequencies and amplifying high frequencies. – Mohammad M Jun 11 '17 at 8:28

Transfer function of a 1st order HP filter is:

$$H(s)=\frac s{s+wc}=\frac{{\displaystyle\frac s{wc}}}{1+{\displaystyle\frac s{wc}}}\;,where\;wc=2\mathrm\pi\ast\mathrm{fc}$$

&

a = [1 w0];
b = [w0 1e-48]; % ! two coefficients
• why not set b = [w0, 0] ? – Ben Jan 15 '18 at 2:03

## Low Pass

Note: Scroll down for High Pass.

I have ran your code by fixing parameters such as $$\tau, f_s, w$$ and i got no error. However, the following is low pass and using 'fvtool' we see that

tau = 1e-3;
fs = 1e3;
w = 0:1e-2:pi;
b = 1/tau;
a = [1, 1/tau];
h = freqs(b, a, w) % LPF
[digital_b, digital_a] = bilinear(b, a, fs)
fvtool(digital_b,digital_a)

This gave me

digital_b =
0.0050    0.0050
digital_a =
1.0000   -0.9900

The figure is as

## High Pass

On the other hand, changing your $$a,b$$ vectors to a transfer function that corresponds to a High Pass as follows for instance

a = [1 1/tau];
b = [1/tau 0];

gives the desired high pass