07-15-2013 11:13 AM
See attached picture (a snipet of the signal) to see what I am talking about.
I would like to get the index of the maximum and minimum points for every second, but these random spikes are interfering with the measurement.
I tried using the median filter vi with ranks of 5 for right and left (I tried values from 1-10, and 5 worked the best), but this has caused problems with the index calculation (the index is higher than it should be based on the graph).
Any ideas on a different filter I should be using? Or am I making an error with the median filter vi?
07-15-2013 12:45 PM
You don't want a median filter. Your noise is at a so much higher frequency than your signal that you can get by with a simple low-pass filter (1-pole Butterworth in the signal processing-> filtering VI palette) with a cutoff of, say, 50 Hz. (You may have to adjust that a bit either way.) Anything more for a signal this clean is overkill. However, any filter will cause a lag of the output relative to the input (index) and you just have to figure out how much that is and compensate for it in your data analysis (it won't change from run to run, so you only have to do this once).
Cameron
07-15-2013 01:33 PM
Another possibility is to use Savitsky-Golay smoothing. You can adjust the number of side points used to get the amount of smoothing you want. This has a time shift just as any other filter does, but it is exactly the number of side points. You can pad the array or shift by the number od side points to eliminate the delay.
Lynn
07-15-2013 02:01 PM
Okay, Lynn, you made me look it up.
For a low pass filter (analog), the phase shift is:
, where w is the filter center frequency and w(0) is the signal frequency (can't do omegas here, I guess).
So, for a 50 Hz filter on a 1 Hz signal (pretty much what the picture shows), the phase shift is 1.14 degrees or 3.18 milliseconds, whatever number of data points that comes out to in the sampling rate Laura121 is using.
I thought about a Savitsky-Golay filter, but it looked like the amount of calculating it would take would not be worth any possible advantages. YMMV.
Cameron
07-15-2013 02:08 PM
Cameron,
I put together a Savitsky-Golay VI several years ago primarily because I wanted to use it for the derivatives. I have since used it several times for smoothing as well. Agreed, it does a fair amount of number crunching, but many times that is not the limiting factor.
Lynn