[Scilab-users] Newbie filter basics

Gary Nelson porpoiseseeker at gmail.com
Mon Apr 15 19:25:31 CEST 2013


On Apr 14, 2013, at 6:58 PM, Michael Dunn <michael.dunn at ubm.com> wrote:

> Thanks very much for your detailed reply Gary. I hope I wasn't unclear though in that I am trying to get a better understanding of SciLab  filtering in particular. I understand filter basics in general, and some not-so-basics too, having been designing analog filters, working with FFTs (& general DSP to a lesser extent), and doing audio engineering for over 30 years. I just am finding SciLab a bit overwhelming & confusing.
> 
My apologies. For sure I misunderstood your question

> "DUALS"? I don't understand.

The FT is a complex function that can be expressed in polar coordinates of Amplitude and Phase

In the time domain, there can be a complex analytic signal with real part x(t) and imaginary part y(t) where y(t) = H[y(t)] where H[] is the Hilbert transform which is a 90deg phase shifter.  We usually just deal with real signals so we don't pay attention to these properties but most modems us complex signal representation as I and Q, QAM and such.

The analytic signal in time is dual to the complex FT in freq domain

In freq domain, atan (imag(f)/real(f)) is phase(f) and d/df(phase) = group delay.  The envelope or magnetude is what we typically call the spectrum; phase is usually ignored, but group delay often is a useful feature. 

In time, the same math applies and the sort(x^2 + y^2) is the time envelope and instantaneous phase is atan(y/x), but d/dt(phase) is instantaneous freq which is dual of group delay.

Analytic signal view is not too helpful if signal BW>octave.

I bought Modeling and Simulation in Scilab/Scicos and got a few good tips from it.

It sounds like you're making good progress actually.  There are a couple good tutorials as well as the book
> 
> I've put filtering aside for the moment – spent most of the day messing with FFTs. Trying to get a Bode plotter working using DUT input & output signals from a scope. Made decent progress, but my phase plots need some work :-}  
> 
> Ah, eureka, just got it :-)
> 
> 
> Michael Dunn | Editor-in-Chief
> Scope Junction | http://www.scopejunction.com/
> UBM Electronics
> (415) 947-6096 (USA)
> (519) 744-9395 (Canada)
> Skype: MichaelDunn_UBM
> LinkedIn: http://www.linkedin.com/in/cantares
> <0037D790-7BC6-4B2E-8F0E-A3D972B2935B[160].png>
> 
> 
> 
> From: Gary Nelson <porpoiseseeker at gmail.com>
> Reply-To: "International users mailing list for Scilab." <users at lists.scilab.org>
> Date: Sunday, April 14, 2013 6:22 PM
> To: "International users mailing list for Scilab." <users at lists.scilab.org>
> Subject: Re: [Scilab-users] Newbie filter basics
> 
>> 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
>> 
> _______________________________________________
> 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/20130415/44b5e9b3/attachment.htm>


More information about the users mailing list