08-13-2024 08:22 PM
Hello Everyone! I really need help developing a 16-sample moving window on an input signal. for each iteration that goes by, the window needs to be able to move one sample to the right. For example, 0 to 15 for the first iteration, 1 to 16 for the second iteration, 2 to 17 for the third iteration, etc. The window needs to be able to sample the signal as well with 16 samples total for the moving window. I am having such a hard time since I was able to make that moving array but being able to make a window out of it and put that window on an input signal is proving to be very hard. Please help me out!
08-14-2024 12:46 AM
08-14-2024 07:02 AM
Sounds like you could just use the Mean PtByPt VI.
08-14-2024 08:30 AM
It looks like you need a circular buffer, the PtBy Pt does that,you can implement that using a while loop with shift register without initializing it.
The buffer is a subvi, with a while loop with a shift register (don't initialize it).
Inside the loop, there is a case structure wired to a control coming from a iteration.
For the iteration =0, the initilize array will create a 15 size array with all the same element from your sample,
As the iteration increases from 1 .. the case has a replace array subset,
Use a quotient /Reminder to divide the iteration by the number of samples, returning the floor of the division, that number will be wired to the index of replace array.
At every new sample, the floor of that division will point to the next position of the array (your buffer). You could use it to then calculate an average (called moving average of your 15 samples.
08-14-2024 08:31 AM
The buffer.vi is then called as a subvi.
08-14-2024 10:14 AM - edited 08-14-2024 10:17 AM
So what do you need to do with the data in the moving window? (average? linear fit? get standard deviation? find min&max? just display it in a graph? something else?) This will determine the best approach.
What should happen before you have 16 points? (truncated? Padded?)
Also, what kind of data is this (dynamic, scalar, waveform, etc. etc.) and how does it arrive?
08-14-2024 12:47 PM
I am basically trying to use the data in the moving window to Plug into the one-cycle cosine filter I linked below. The value that I am plunging in for is x(k), basically the input single and sample k, but this window needs to be constantly moving to the right 1 sample each iteration meaning the value of k will always be changing and therefore the data at y will also always be changing. I hope this clears stuff up. The input will just be a standard sine waveform that would ideally have noise to isolate the fundamental frequency which is what the one-cycle cosine filter does but for now I am just working with a 1 amplitude 60hz sine wave generator as the signal input to make sure the frequency between the input and output line up.
08-14-2024 12:57 PM
Please look at the reply at one of responders on this post, I hope it'll clear stuff up!
08-15-2024 01:17 AM - edited 08-15-2024 01:23 AM
Hi Pete,
@Havordpete wrote:
I am basically trying to use the data in the moving window to Plug into the one-cycle cosine filter I linked below. The value that I am plunging in for is x(k), basically the input single and sample k, …
I don't see the need for a "moving window" in this formula.
You already have a waveform (consisting of several samples) and could easily apply this formula to your array of samples!
Suggestion:
08-15-2024 05:28 AM
Thank you so much for the solution Gerard!! Before I ask any questions about your setup, is it possible to attach the code script for your setup? Or make some kind of VI and attach it in your message? I would greatly appreciate it!