Monday, May 25, 2009

Filter Design using Scilab

Scilab is an open source software for numerical computation. The software could be download freely from scilab website. AS open source software, we could participate to develop the library of this software. In this article i would like to explain how to design filter using signal processing tool in Scilab. As we know that base on frequency respon filter could be classified into:

- Low Pass Filter (LPF): allow signal which as lower frequency than the cut off frequency.
- Band Pass FIlter (BPF): pass signal from cut off frequency fc1 to cut of frequency fc2
- High Pass Filter (HPF): admit the signal over the cut of frequency
- Band Rejection: reject signal starting from cut off frequency 1 to cut of frequency 2.

Filter coud be used to get the desired signal for example when EKG signal is disturbed by noise wich has lower frequensi signal.

The following will be simulated noise cancellation using generated signal. Original signal is sinusoidal signal 5 Hz for 4 seconds. The noise is sinusoidal signal 50 Hz which also has 4 seconds time.

t = 0:0.001:4
signal = sin(2*%pi*5*t);
noise = sin(2*%pi*50*t);
compound = signal + noise

To seperate the signal from noise, we could use low pass filter. The important note is how to decide the cutt off frequency of the system. Using Scilab, we can use available technique to design the filter such as Butterworth, Chebisev and elliptic.

Deciding the cut of frequency is very easy by looking at freuency of signal and noise. In this case we select the frequency beetween signal and noise. The normalization of 5Hz is 0.005 and 50 Hz is 0.05.

myfilter = iir(15,’lp’,'butt’,[0.025 0],[0 0]);

- The first parameter is filter order. We could use higher order filter but please remberber taht higher order filter increase the number of calculation iterations.
- Second parameter is filter type which lp= lowpass, hp=highpass, bp=bandpass.
- Third parameter is technique which is used to design. This example use Butterworth. It is also availabe other methods such as cheb1, chep2 dan ellip.
- Fourth parameter is cut of frequency in normalization form
- Fifth parameter is error vector whic is used only in chebisev and elliptic technique

To apply filltering to the signal, we could write the following code:

output = flts(compound,myfilter);

Let we plot the input and output of this filter.

xtitle(’input signal’)
xtitle(’output signal’)

The script will show input signal and output signal of LPF which just been implemented.

written by: Dhidik Prastiyanto

1. Lecture Note by Dhidik Prastiyanto
2. Introduction to signal Processing (Roman Kuc)



  1. Small business websites are setup for introducing business to the web audience. One can't expect a wealth of knowledge from such websites. The design should be concise and clear enough to understand main objective of business.small business website design

  2. Automated cutting and welding of tubular parts can be an excellent way for a metal fabrication company to reduce costs and manual efforts in its manufacturing operation. The consistency that is needed for critical automated welding can be achieved by creating an automated work station in the production process. weld edges

    1. Hello - I am contacting on behalf of my client. We are requesting the comment above by Joe be removed. This article and link in the comment is irrelevant to my client. Thanks!

  3. Nice code, thanks. This is a big help to me.

    Typing errors with some of the single quotes.

    Richard Mullins