[Scilab-users] Newbie filter basics

Gary Nelson porpoiseseeker at gmail.com
Mon Apr 15 00:22:49 CEST 2013


Filtering and Fourier analysis are called DUALS. [If you want to actually "understand" the topic, you will want to learn about complex numbers and calculus, then fourier analysis, sampling and stuff like that.  You can get a qualitative grip by playing with the open source audio eidtor called Audacity -- no better tool to learn with. Suggest you download it and try some filtering and signal creation there for starters]

Multiplication on one domain is paired with convolution in the other.  Filtering a signal can be viewed as multiplying its fourier transform by the fourier transform of the filter ('s impulse response to be more complete).
Or, one can filter a time signal by convolving it with a window of samples.  Stock analysts do this all the time and call it a moving average -- take N consecutive data samples, add them up and divide by N and call that one number a sample in the filtered result.  Move the window over to the right one sample and do it again to get a second filtered sample. Slide that N size window along the data and watch the output have fewer wiggles. Make N larger and get less wiggles. You can do this on Yahoo with some stock valuation. A moving average is a convolution of your stock data with a filter window the is N samples long and each sample has value 1/N. If you imagine a moving average as a simple filter, then computing the moving average is convolution of the data with the impulse response of the filter which happens to be the N samples of 1/N value. So line up the filter with the data and multiply all the sample-filter pairs and add to get one result sample, and move to the right and do it again until you run out of data.  That's filtering by convolution in the time domain.  A moving average is one implementation of what we call a LOW-PASS Filter.

Conversely,, multiplying two time domain signals is paired with convolution of their respective fourier transforms. This is important when you encounter a choice of windows on a spectrogram, but that is for another lesson

If you use Audacity as a learning tool, you can create a signal composed of a tone (e.g., 44o Hz) plus some noise.  Now use that little pull down at the left of the track and select Spectrogram and see a frequency vs time vs amplitude out of the screen via color. Go to preferences/spectrograms and choose length as say 16 samples.  Now look at the screen and see 8 rather distance bands for the 8 frequency bins enabled by choosing observation windows of 16 samples.  Now go back to Preferences/Spectrograms and choose size of 32 or 64 and try to count up the frequency bins.  The number of frequency bins is always 1/2 the number of time domain samples for real signals which is waht we mostly deal with.

You can go to Effects/Equalization and choose to draw filters on a frequency vs amplitude chart. Try to draw a filter that is flat between say 1000 and 2000 Hz and pull the curves down as low as possible to left and right and say go.

This a BAND-PASS filter. 

When you look at the resulting spectrum, you will see that the signal is mostly gone above and below the 1000-2000 frequency window,

  If you filter out the lows and leave the highs, you will have a HIGH-PASS filter.

Once you get the hang of filtering with Audacity, you can come back to SciLab and try using the FFT and convolution functions.  Moving averages are a great way to get the feel of low pass filters.  Then move up to doing an exponentially weighted moving average which is available for test on yahoo finance.  That just says older samples have less influence than recent data,  Wikipedia has a couple good pieces on this topic as well; see convolution and fourier analysis for starters.


Gary Nelson
porpoiseseeker at gmail.com



On Apr 13, 2013, at 4:12 AM, Adrien Vogt-Schilb <vogt at centre-cired.fr> wrote:

> On 13/04/2013 02:49, Michael Dunn wrote:
>> Hi. Are there any resources or tutorials or references out there that would be helpful to  a newbie to SciLab filtering functions? I just want to filter some data – at this point, I don't even care what kind of filter – just want to learn how!
>> 
>> At first, I thought I'd try an IIR, but I couldn't figure out how to generate the coefficients.
>> //y = filter(num,den,x)  
>> 
>> Then, I stumbled onto ffilt, which seems to generate FIR coefs, but where's the actual FIR filter function? Is it "convol"? I tried this:
>> 
>> plot(fft(convol(ffilt("hp",40,100),r)))
>> It does something, but I'm not sure what. Am I getting close?
>> 
> Hi
> 
> I am not used ot filters, but I know there is a how to here: http://help.scilab.org/docs/5.4.1/en_US/DesignEllipticFilter.html  (this is available in french also)
> from there, i suggest you navigate throught the "see also sections"
> 
> you can also have a look here: http://help.scilab.org/docs/5.4.1/en_US/section_dbbac6be408104de3049eddefaf6b9c9.html
> 
> the content of this webpage is also available in your computer, type "help" in the console and navigate.
> 
> I hope the "how to" (1st link) will help you
> 
> 
> 
> 
> 
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20130414/9fd7242e/attachment.htm>


More information about the users mailing list