LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mean From Array

Solved!
Go to solution

Hello, I currently have an array. A set of X-values and 3 different Y-values for each of those X-values. I am needing to take the average of those 3 Y-values of each X-value, not all the Y-values in my data and spit back out the information containing the X-value along with the average of the 3 Y-values. 

0 Kudos
Message 1 of 4
(2,852 Views)

Have you tried writing out (pencil and paper, only) a flow-chart or "scheme" to solve this problem, starting with a text file that appears of have lines consisting of text representing 4 numbers/line?  Here's an example:

  1. Read a line of text.
  2. Parse line into an array of 4 numbers.
  3. Split Array into 1 number (X) and array of 3 numbers (Y).
  4. Take the mean of the Array of Y, giving now X (from step 3) and Y.
  5. Accumulate X in X Array, Y in Y Array.
  6. If still more numbers in file, go back to Step 1.
  7. When finished, should have X Array and Y Array (as the mean of the 3 Y numbers).

Obviously, you now need to translate this pencil/paper "program" into LabVIEW.  This will involve (a) file I/O of text data, (b) parsing text data to create arrays of numbers, (c) working with array to return mean, (d) looping and creating array(s) from values arising from each loop iteration.  These are all fairly simple LabVIEW concepts that should be covered in the many Learning LabVIEW Tutorials (including the ones listed on the first page of this Forum).  The best part of all is that by doing this yourself instead of having one of us do it for you, you will learn LabVIEW.

 

Bob Schor

Message 2 of 4
(2,848 Views)

First read the file with the Read Delimited Spreadsheet to give you a 2D array of doubles.  Then wire that into a FOR loop.  Inside the loop, you are just dealing with a row.  So use Delete From Array with 0 wired to the element (length left unwired).  You can now do a Mean with the remaining array and autoindex that value out of the loop, resulting an array of averages.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 4
(2,847 Views)
Solution
Accepted by topic author ValdoRey

Hi. It's exacly as said in the post before mine :Mean.png(snippet attached)

 

 

Message 4 of 4
(2,828 Views)