From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Taking multiple measurements at trigger, then calculate mean and save to file

Solved!
Go to solution

In the file attached, an array of binary numbers is used as trigger. When the trigger outputs 1, the element in the other array (data array) is recorded at the same index in the trigger array (this index can be shifted by the "index shifter").

 

What I would like to achieve:

When the trigger outputs 1, N number of elements of consecutive index is measured from the same index in the trigger array. The constant N can be changed via a control. And then these consecutive measurements are averaged and recorded to a text file.

 

Example: If N=3

Trigger array           Data array

index element         index  element

0       1                      0        1

1       0                      1        2

2       0                      2        3

3       1                      3        4

4       0                      4        5

5       0                      5        6

 

(1+2+3)/3=2        (4+5+6)/3=5

 

Outputs: 2      5

 

Any help is greatly appreciated, thank you!

0 Kudos
Message 1 of 2
(2,231 Views)
Solution
Accepted by topic author DrWang
  • Array Subset will return a portion of an array of specified length starting at the index you want.
  • Once you get the subset you are after, you can use Mean.vi.
  • To write an array to a spreadsheet easily you can use "Write Delimited Spreadsheet", I think it was called "Write to Spreadsheet" in older versions.
  • Your array of "binary" data can be expressed with booleans, which means less comparisons. 
  • There's no need to initialize an array with a single element, that will just put an extra 0 in your data. You can use an empty array. To add on to it you can just use build array.
Message 2 of 2
(2,223 Views)