LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Selective continuous averaging

Hi there

 

First time user here. I have a really silly question, but cannot seem to figure it out. I have a program that collects data using two different WHILE loops. The innermost WHILE loop (the "second") scans our device over predefined data points at constant incriments (say, 5 equally spaced data points).  

 

The outermost WHILE loop (the "first") repeats the innermost WHILE loop a number of times, to reduce noise.  

 

Here's the tricky bit: for each successive iteration of the innermost while loop, it scans fewer and fewer data points (eg for i=0 it scans 5 points, and for i=1 it scans 4 points, and for i=2 it scans 3 points and so on).  

 

For visualization purposes, we are interested in seeing the scans as a function of index, averaging each points as they go (not when the innermost is completed, but one at a time). 

 

What I am trying to do is get a visual representation of the averaging on a continuous basis. If averaging would not be in place, here's some example numbers (outermost WHILE loop comes before colin):

 

0: 1, 2, 3, 3, 0  

1: 5, 2, 0, 2 

2: 9, 2, 7 

3: 5, 2

4: 4

 

This is easy enough. Using the same numbers, but averaging as we go, 

 

0: 1, 2, 3, 3, 0,

1: 3, 2, 1.5, 6, 0  

2: 6, 2, 4.25, 6, 0 

3: 5.5, 2, 4.25, 6, 0 

4: 4.75, 2, 4.25, 6, 0   

 

It is important that the rescans average each individual point as they go. Does this make sense? Sorry for the crude technology.  Thank you so much everybody.

 

JC

0 Kudos
Message 1 of 2
(2,165 Views)

One reason I could see this happening is that you are somehow wiring your index variable from your outer loop for the condition in your inner loop. Certainly make sure these are seperate. Also make sure nothing none of the arrays you pass into the while loops are unintentionally autoindexing (when you pass an array to a while loop, it will autoindex if the node where it joins the while loop is a set of square brackets "[ ]"). And where you do have autoindexing and intend to have it, make sure when you pass in the array that it is the size you intend it to be.

 

Good luck!

0 Kudos
Message 2 of 2
(2,146 Views)