09-17-2018 04:41 PM
I have a requirement to average the middle 100 samples of a 200 sample acquisition from an analog port of a USB-6212.
I was able to acquire the 200 samples, however, can someone suggest algorithms to skip the first 50 samples and average the next 100 samples?
Do I collect the 200 samples into an array and do the calculations from the array? How will that work in a vi?
Thanks in advance for any help.
Solved! Go to Solution.
09-17-2018 04:49 PM
Use Array Subset. Start at 50, length =100
09-17-2018 05:09 PM
If I have a DAQmx Read with Analog Wfm 1Chan NSamp, is that considered an array?
Would I then just use the Array Subset that you mentioned?
Otherwise would I have to use an Insert into Array and then use the Array Subset?
Thanks
09-17-2018
05:14 PM
- last edited on
01-02-2024
03:04 PM
by
migration-bot
Being that it is a waveform data type, the array of values (doubles) is stored as a component (Y) of the waveform. You can use the Get Waveform Components VI to extract this data, and then perform your averaging as mentioned above.
https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/get-waveform-components.html
Another option, depending on what is required by your application, would be to read the samples as Doubles instead of Waveforms which would remove that extra step. This is assuming you don't need the timestamp or timing information that the Waveform data type provides.