Two examples of frequency manipulation

Butterworth Filters



We will use a low pass and a high pass Butterworth filter to separate the intra day variations of the temperature from its inter day variation.

We will not build here the functions that compute low pass or high pass Butterworth filter. It is, however, of interest to program the computation of a normalized (with cutting frequency 1) Butterworth filter of order N.

This filter is defined as follows
  • it is an analog filter
  • It has a rational transfer
  • It has a static gain of one
  • its transfer has no zero
  • it has N stable poles which
  • are the N stable roots of the unit at order 2N if N is odd, N>2
  • are the stable complex numbers in the set obtained by multiplying the roots of 1 of order 2N by exp(i*pi/2*N)

It should be noticed that, in both cases, the set of complex numbers from which we select the poles is symmetrical both with respect to the real and imaginary axis, and that there is no complex on the imaginary axis. So what is really required is the knowledge of these complex numbers is their value in the first quadrant of the complex plane.

[z,p,k] = MinesButtap(N)

returns the zeros, poles and static gain of the normalized Butterworth filter of order N.

This is not very difficult; try to program it by yourself. Draw a plot of the roots of the unit to help. The more complicated functions are available for download lower in this page.

The solution is here. Download and save.

You can download the following functions:

function [] = MinesPlotAnalogTransfer( num,den,endFreq,numSamples)
%plots the magnitude of the rational transfer num/den
% with numSamples frequencies ranging from 0 to endFreq/(2*pi)

function [num,den] = MinesU_buttap(N,OmegaC,frequencyNumber)
% returns the numerator and denominator of Butterworth filter
% of order N and cutting frequency Omegac
% in continuous time
% optional argument frequencyNumber specifies the number of
% frequencies at which that absolute value of the transfer
% should be plot.

function [ num,den ] = MinesU_buttapHigh(N,OmegaC,frequencyNumber)
%computes the Analog High Pass Butterworth Filter with cutting freq. OmegaC
%N is the order of the original lowPass filter
% in which the Lapace variable s is replaced by OmegaC/s

You will also need the following utilities:

function [ bz,az ] = Mineszmapping(bZ,aZ,Nz,Dz)
%rational substitution; replaces rational
% in Z by rational in z according to a rational
% expresssion of Z as a function of z
% Does not require degree(D) = degree(N)
% Specifically we have
% b(z) b(Z)|
% ---- = ----| N(z)
% a(z) a(Z)|@Z= ----
% D(z)

function [ powers ] = MinesPowersPoly(p,N)
%computes the powers of polynomial p up to the order N
% p must be line oriented
% powers is a matrix of (N+1) line
% line i of powers gives the (i-1)th powers of p
% padded with zeros at the beginning of the line

function [ num,den,simplified ] = MinesCancellation( N,D,tol )
%simplifies poles and zeros in a rational fraction within
% the tolerance tol. Relies on the Matlab 'roots' function.
% simplified is the vector of the roots that have been simplified
% N and D are assumed to be non empty and non zero.
% simplification is tested against roots that are normalized to 1.
% tol cannot be very small.