Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use the SavitzkyGolay.Filter method correctly

Hi,

I have not found very much information on how to use the Savitzky-Golay filter correctly with VB.net. It only takes a one-dimensional array and when I try to feed data into it, I get Specified conditions on the input arrays have not been met. Analysis Error Code: -20008. I'm not sure if I am entering a correct side point number in the function either (is it the total number of points or is it (2*(totalpoints)+1)?). Either way I still get the same error message as shown above. I'll post a code example below and hopefully someone can help me or show me what I am doing wrong. I just threw something together at random to try out that's in VB.net.

 

Dim I As Integer = 0

Dim arr(99) As Double

Dim myArr(99) As Double

For I = 0 To 99

arr(I) = Rnd(1500)

Next

myArr = NationalInstruments.Analysis.Dsp.Filters.SavitzkyGolay.Filter(arr, 2, 2 * 100 * (2) + 1)

 
Thanks!
0 Kudos
Message 1 of 3
(4,617 Views)
Hey Nazeiter,

The sidePoints parameter specifies the size of the frame in which you apply this filter on the signal.  The frame size needs to be less than the total number of data points.  In your example above, the frame size could be 10 and the function would apply its FIR filter on every 10 consecutive points.  Also, you can find more information on different exceptions that can occur with the SavitzkyGolay.Filter function in the .NET help.  I hope this helps!
Best Regards,
Software Engineer
Jett R
0 Kudos
Message 2 of 3
(4,600 Views)
Jett,
 
Thank you, that did the trick. I'm really sorry about that, I didn't have a good understanding of the framesize.
 
Thanks!
 
Nate
0 Kudos
Message 3 of 3
(4,596 Views)