08-31-2012 08:06 AM
Hi, I'm new to labview. Is there an easy way to index through the dynamic data returned from an DAQmx analog read of x samples to compute a running average? My thinking was to read the analog input for X samples then pump the data through another loop to average the data, but I can't quite figure out how to index through the data set returned to extract the double measurement value returned for each sample.
Any ideas on this?
Thanks...
Solved! Go to Solution.
08-31-2012 09:14 AM
You can use the Convert From Dynamic Data function to get an array or waveform data type. No need to index anything to get an average. Just pass it to the Mean funciton. If you want to stick to dynamic data and not do any conversion, use the express Statistics function. No indexing required either.
08-31-2012 09:48 AM - edited 08-31-2012 09:48 AM
@Dennis_Knutson wrote:
You can use the Convert From Dynamic Data function to get an array or waveform data type. No need to index anything to get an average. Just pass it to the Mean funciton. If you want to stick to dynamic data and not do any conversion, use the express Statistics function. No indexing required either.
Thanks for your response. I'm using the Analog 1D Wfm NChan NSamp command to sample the analog input for x samples. It returns multiple waveforms, so I assume the Convert From Dynamic Data function will not convert it properly, at least it won't resolve for me. Is there away to sample the analog port for NSamp using one channel to get one waveform of data back since I really only need to sample one channel at a time to return one waveform. If you see my example you will see that I can't pass the converted waveform into the mean function. I'm sure I'm doing something stupid and I'm sure there is a simpler way 😃 Any ideas?
Thanks.
08-31-2012 10:14 AM
If you are getting a waveform data type, why did you ask about dynamic data? No, of course you would not use the Convert From Dynamic Data on a waveform.
If you only want one channel, then your DAQmx Read could be changed to 1Chan NSamp. If your channel list only has a single channel in it, you will only get a 1D array with a single element that can be indexed. To get the mean of a waveform use the Statistics function with the waveform. You are using the Mean Point by Point and not the Mean function which has an array for an input.
Make sure you always have Context Help turned on. You can avoid a lot of these simple beginner mistakes.
08-31-2012 10:41 AM
Thank Dennis. There is so many ways and so many functions to sort through. I figured it out though based on you reply.
Thanks.