Search tips

# Discussion Groups | Comp.DSP | C code for implementation of low pass filter to time series signal

There are 4 messages in this thread.

You are currently looking at messages 1 to .

Is this discussion worth a thumbs up?

0

# C code for implementation of low pass filter to time series signal - helen - 2006-09-07 09:55:00

```I am doing C programming for low pass filtering time series signal and then
downsampling the signal.

Is there any available C source code for dummies?
For instance, given filter coefficients, h[n], and signal
x[numberofSamples], how shall I get the filtered signal ??

Thanks```

# Re: C code for implementation of low pass filter to time series signal - Tim Wescott - 2006-09-07 10:45:00

```helen wrote:
> I am doing C programming for low pass filtering time series signal and then
> downsampling the signal.
>
> Is there any available C source code for dummies?
> For instance, given filter coefficients, h[n], and signal
> x[numberofSamples], how shall I get the filtered signal ??
>
> Thanks
>
Is this a finite impulse response filter (FIR), or an infinite impulse
response filter (IIR)?

If it's a FIR then you just take the last N samples and multiply them
sample-for-sample by the filter coefficients, so for sample n you'd use:

out[n] = sum from {k = max(0, n - N)} to n {x[n - k] * h[k]}

control system design it does go into the implementation of IIR filters:
http://www.wescottdesign.com/articles/zTransform/z-transforms.html.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html```

# Re: C code for implementation of low pass filter to time series signal - Jim Thomas - 2006-09-08 09:58:00

```helen wrote:
> I am doing C programming for low pass filtering time series signal and then
> downsampling the signal.
>
> Is there any available C source code for dummies?
> For instance, given filter coefficients, h[n], and signal
> x[numberofSamples], how shall I get the filtered signal ??
>

You might find this useful:
http://www.dspguru.com/info/faqs/firfaq.htm

Good luck.

--
Jim Thomas            Principal Applications Engineer  Bittware, Inc
j...@bittware.com  http://www.bittware.com    (603) 226-0404 x536
There's a fine line between clever and stupid```

# Re: C code for implementation of low pass filter to time series signal - dilpreet06 - 2006-09-08 19:35:00

```I have the C++ code for convolution :

iCoefficients can be the FIR / IIR Coefficients, iIndex is the Index
number of the vector that is being filtered.
vec is the typedef for std::vector<double>

For an IIR filter your code would look like:

filteredData[i] Convolution(i,input,BCoefficients)-Convolution(i,filteredData,ACoefficients);

double Convolution(int iIndex, vec& iData, vec& iCoefficients)
{
for(int l=0; l<iCoefficients.size();l++)
{
if((iIndex-l-1)>=0)
{
}
else
{