-->t = 0.01:0.01:3; -->length(t) ans = 300.Now we are going to add two signals, one of them similar to an alpha rhythm (a sinusoid at 10 Hz) and the other one similar to a pulse (a sinusoid at 1 Hz with double voltage)
-->eeg = sin(2*%pi*10*t); -->pulse = sin(2*%pi*1*t); -->inp = eeg + 2 * pulse;Now we are going to design the filter to eliminate the pulse and extract from the signal the `eeg'. We will use a filter of order `10'. Since we want to extract the sinusoid at 10 Hz and to eliminate the sinusoid at 1 Hz, we need a `high pass' filter and will use a Butterworth filter. The most difficult step is to discriminate the cut-off frequency. In Scilab, frequencies are expressed in relation to sampling frequency. Since we are using sampled signals, the possible frequencies span from 0 to 0.5. A sinusoid at a frequency of 10 Hz with a sampling frequency of 100 Hz corresponds to 0.1 (10/100), a sinusoid at a frequency of 1 Hz sampled at 100 Hz corresponds to a frequency or 0.01 (1/100). So to discriminate among these signals we can use a cut-off frequency of 0.05.
-->lisys = iir(10,'hp','butt',[0.05 0],[0 0]); -->out = flts(inp,lisys);Now we can see the result with the following code:
-->xsetech([0,0,1,1/2]) -->plot2d(t,inp) -->xtitle('original signal') -->xsetech([0,1/2,1,1/2]) -->plot2d(t,out) -->xtitle('filtered signal')And this is the result:
Now, imagine that we have sampled the same signal at 200 Hz and then the sampling period should be 0.005.
-->t = .01:.005:3; -->eeg = sin ( 2 * %pi * 10 * t); -->pulse = sin (2 * %pi * 1 * t); -->inp = eeg + 2 * pulse; -->lisys = iir (10, 'hp', 'butt', [0.025 0],[0 0]); -->out = flts (inp, lisys);The result is the same. Notice that we have to discriminate between a frequency of 10 Hz equivalent to 0.05 (10/200) and a frequency of 1 Hz equivalent to 0.005 (1/200). We elected a cut-off frequency of 0.025 equivalent to 5 Hz (200 * 0.025). So, to define the filter, is vital to consider the sampling frequency.
In this section we have considered a signal formed by the addition of two sinusoids and tried to eliminate the slow components. We have sampled the signal at two sampling rates (100 and 200 Hz) and designed a high-pass filter. When we sample the signal at 100 and 200 Hz, the coefficients of the filter are different.
The next section is dedicated to the study of the properties of the filter designed to eliminate frequencies under 5 Hz sampled at 200 Hz.