×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to filter out data ?
2

How to filter out data ?

How to filter out data ?

(OP)
I have two columns of data (50,000 points) in an excel file (.CSV) that needs to be filtered down from 20hz to 5hz. How would I go about doing this?
ie I need the data to filtered down to 12500 data points evenly.

RE: How to filter out data ?

(OP)
If I load the original .csv file in matlab, is it possible to extract data points - then export into csv format?.

RE: How to filter out data ?

Yes, you could load it into Matlab and take every 4th point. But you need to be careful. If the 20Hz sample frequency signal contains frequencies greater than 2.5 Hz then you need to filter them out or your 5Hz sample rate signal will be aliased.

M

--
Dr Michael F Platten

RE: How to filter out data ?

2
Luckily they have thought of that and the excellent decimate function in matlab will antialias your data and then downsample it.

DECIMATE Resample data at a lower rate after lowpass filtering.
    Y = DECIMATE(X,R) resamples the sequence in vector X at 1/R times the
    original sample rate.  The resulting resampled vector Y is R times
    shorter, i.e., LENGTH(Y) = CEIL(LENGTH(X)/R). By default, DECIMATE
    filters the data with an 8th order Chebyshev Type I lowpass filter with
    cutoff frequency .8*(Fs/2)/R, before resampling.

alternatively you could take a 4-8 point moving average of the data in excel and pick every 4th point. Not too sure what the frequency response of a moving average is, but I don't need to.
 

Cheers

Greg Locock

SIG:Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

RE: How to filter out data ?

Ooooo. Nice function. Shame we don't stretch to the signal processing toolbox.

M

--
Dr Michael F Platten

RE: How to filter out data ?

(OP)
Greg that seems to be working. I have two columns of data. Does that mean that I need to apply the filter to each column separately?.
Also, decimate is not accepting 4.5 for R. Is there any way around this (this is to get 20hz down to 8hz)?
 

RE: How to filter out data ?

That's new to me too.  Thanks Greg.

- Steve

RE: How to filter out data ?

"I have two columns of data. Does that mean that I need to apply the filter to each column separately?."

Yes, vector is matlab speak for a one dimensional array

"Also, decimate is not accepting 4.5 for R. Is there any way around this (this is to get 20hz down to 8hz)?"

That is an odd and unnecessary restriction, they might have done it for speed.

Two ways, (1) roll your own, by filtering and then downsampling or (2) upsample using interp1 to a sampling rate that can be decimated to 8 hz, eg 40 hz. I'd use linear interpolation.

The latter might seem a bit bizarre but since it uses canned routines may be faster than rolling your own.



  

Cheers

Greg Locock

SIG:Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

RE: How to filter out data ?

Instead of rolling your own try resample. Basically what you are trying to do has already been done a million times before and perusal of matlab's help files will get you the right answer.

 RESAMPLE  Change the sampling rate of a signal.
    Y = RESAMPLE(X,P,Q) resamples the sequence in vector X at P/Q times
    the original sample rate using a polyphase implementation.  Y is P/Q
    times the length of X (or the ceiling of this if P/Q is not an integer).  
    P and Q must be positive integers.
 
    RESAMPLE applies an anti-aliasing (lowpass) FIR filter to X during the
    resampling process, and compensates for the filter's delay.  The filter
    is designed using FIRLS.  RESAMPLE provides an easy-to-use alternative
    to UPFIRDN, relieving the user of the need to supply a filter or
    compensate for the signal delay introduced by filtering.
 
    In its filtering process, RESAMPLE assumes the samples at times before
    and after the given samples in X are equal to zero. Thus large
    deviations from zero at the end points of the sequence X can cause
    inaccuracies in Y at its end points.

Cheers

Greg Locock

SIG:Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now