09-11-2008 05:34 PM
Hello,
Attached is an example of my vi file where I capture data for n iterations and then get a final average of the iterations for only the y-data values.
09-11-2008 05:36 PM
Attached is an example of my vi file where I capture data for n iterations and then get a final average of the iterations for only the y-data values. I then plot the final x- vs average y-data. Is there a way to plot a graph of the average y-data after each iteration instead of just at the end?
Thanks,
hiNi.
09-12-2008 12:32 AM
Just place a graph in the "For Loop".
You should really connect wires from left to right.
09-12-2008 12:48 PM
Hello,
Firstly, is there a way to get the average of the y-data after each iteration? The way of how I have it set up, the average of the y-data only comes out at the end of the iterations? Can you assist me in getting the average of the y-data after each iteration?
Thanks,
hiNi
09-12-2008 02:41 PM
This is another very basic LabVIEW task. You have the orange wire going to your Y data indicator. Browse to the Mathematics>Probability and Statistics palette and select Mean. Wire it up. You could also simply drag a copy of your existing average calculation to inside the loop.
Please see the free LabVIEW training.
09-12-2008 03:53 PM
Hello,
OK, I selected the mean function as you recommended, however, I'm having a problem with the task that I originally asked help for. I was unclear. I apologize. However, this is what I would like to get some help to accomplish:
After the first iteration, the data might be:
x-data y-data (iteration #1)
1 .10
2 .30
3 .50...
The graph of the average response after the 1st iteration will have data points:
x-data y-data (Average)
1 .10
2 .30
3 .50...
For the second iteration, the raw data might be:
x-data y-data (iteration #2)
1 .30
2 .10
3 .30...
The graph of the average response after the 2nd iteration will have data points:
x-data y-data (average of iteration #1 and # 2)
1 .20 ((0.1+0.3)/2)
2 .20 ((0.3+0.1)/2)
3 .40 ((0.5+0.3)/2)...
For the third iteration, the raw data might be:
x-data y-data (iteration #3)
1 .40
2 .80
3 .10...
The graph of the average response after the 3rd iteration will have data points:
x-data y-data (average of iteration #1 and # 2 #3)
1 .30 ((0.4+0.2)/2)
2 .50 ((0.8+0.2)/2)
3 .25 ((0.4+0.1)/2)...
Thanks,
hiNi
09-13-2008 10:38 AM - edited 09-13-2008 10:45 AM
Hi hiNI,
well, what you describe isn't exactly something called a running average usually...
To get your desired result simply add the new data to theold ones and divide by 2 - it's as simple as described as LabView processes arrays the same way as scalars.
To have a "real" running average simply search this forum, you will find more than one example!
09-13-2008 12:01 PM - edited 09-13-2008 12:04 PM
hiNI wrote:
After the first iteration, the data might be:
The graph of the average response after the 1st iteration will have data points:
The graph of the average response after the 2nd iteration will have data points:
x-data y-data (average of iteration #1 and # 2)
The graph of the average response after the 3rd iteration will have data points:
x-data y-data (average of iteration #1 and # 2 #3)
All you need to do is sum the Y data array in a shift register and divide by the number of iteration (i+1) for display and further processing.
You code makes no sense, because you generate random x values and also average those. I assume x= constant and just the array index, else nothing would make sense. I also don't know why you generate 2D arrays with stacked FOR loops and then slice out the only data row. Way too much code!
Since X is constant and equally spaced, you can use a waveform graph. Here's a simple example, see if it makes sense. 🙂
It is not a "running average" of e.g. the last x traces, but an average of all N acquisitions as you specified
09-15-2008 10:58 AM
THANK YOU!
That was exactly what I needed!!!
hiNi