LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How does one use averaging with a for-loop?

I'm using Labview Express 7.0 and i was working on a VI and came across the concept of averaging data points for better accuracy. I would like to know how to do this. I have read a little bit about shift registers and kind of understand that, but I'm not too clear on how to average my data points in a for-loop.
0 Kudos
Message 1 of 18
(3,812 Views)
Hi,

If I understood correctly, you want to make an average within a for loop.
First of all you have a function to average an array (if you have it available in an array), but of course you can use shift registers to make that.
I made a small example to show you the two ways.

Hope this helps,
Paulo
0 Kudos
Message 2 of 18
(3,806 Views)
More information is needed in order to answer your question. What is the source of your "data points"? Are you trying to average all of the data points, or are you trying to average the last x number of data points? If so, is x a constant or a variable? Once you have the data points that you are interested in averaging into an array performing the average is easy. Just use the "Mean" function under the Analyze-Mathematics-Probability And Statistics palette in the functions palette.

Message Edited by John Rich on 06-29-2005 11:17 AM

0 Kudos
Message 3 of 18
(3,807 Views)
Try using the decimate array.vi on the output of the for loop. right click in the block diagram, go to Analyze, Signal Processing, Time Domain menu.
0 Kudos
Message 4 of 18
(3,796 Views)
I'm aquiring my data from a mass spectrometer in increments of .5 amus. I'm reading the intensity. Instead of reading the mass spec. and graphing it right away, i would like to take 10 readings and average those. I would then take the average value and graph it on the xy graph. I don't understand how i'm going to read it ten times and take the average of the readings and plot them on the graph.
0 Kudos
Message 5 of 18
(3,786 Views)
How are you communicating with the mass spectrometer? Are you wanting to take ten readings at each increment and then increment or take ten complete spectra and average these? I've not used a mass spectrometer but I suspect that you can do the former, which will most likely be the best option. Can you attach your code or at least an examples which shows the communication with the mass spectrometer?
0 Kudos
Message 6 of 18
(3,781 Views)
I want to take 10 at each increment and take the average to plot on the xy graph.
0 Kudos
Message 7 of 18
(3,777 Views)
How do you communicate with the mass spectrometer? Do you send a command to go to the next increment, wait for a response, and then send a command to take a data point? If so you should be able to send the command ten times to take the data point before incrementing again. You do this by putting the "Read value" function inside a for loop for 10 iterations. Enable indexing of the data output at the side of the for loop. You now have the array that you need for averaging.
0 Kudos
Message 8 of 18
(3,775 Views)
Would the point-by-point averaging function alternatively be of use? Search for it and other pbp vi's in help
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 9 of 18
(3,770 Views)
Here is the application, maybe someone can give me some better advice after looking at it.
0 Kudos
Message 10 of 18
(3,767 Views)