LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build a four element array with one input

Hello everyone.  I have a problem with building an array.  The premise is that I am taking four measurements from a spectrum analyzer.  From there I need to take the peak amplitude and store it in an array.  From there I need to sum the measurments and then divide by four to get the average.   Then I am sending that data to the MS office VI so that it goes to a custom excel template.  I have tried using a for loop with the initialize array and index array function.  However this has not been the right answer.  Any help would be appreciated.  Thanks.  


LabVIEW 8.2
0 Kudos
Message 1 of 6
(3,016 Views)
Need more input. How are you getting the measurements? Is it a VI that returns a single measurement that you need to call 4 times, or is it a VI that returns an array with four measurements, or is it a VI that returns an array with a whole bunch of measurements, and you need to pull out 4 of them?

If you have a VI that returns a single measurement, like querying the marker value, you just need to put this in a for-loop that runs 4 times, and use auto-indexing to get yourself an array of 4 measurements. You can use the built-in "Mean" function to get your average of the values, and the "Array Max & Min" to get your maximum value. You didn't say how this MS Office VI takes these inputs, so it's not clear whether these are supposed to be bundled, or appended to the array.
0 Kudos
Message 2 of 6
(2,998 Views)
Thanks for replying.  I am getting the measurments from HP 8563E and 8562A spectrum analyzers.   I am measuring a CW carrier four times each are different values.  The VI returns one measurment for each iteration.  I need to take those four measurments add them together divide by 4 and get an average.

So I should put the measurment into a for loop and auto index that information into an array?  Should I use the build array or index array function? 

MS Office VI is taking these inputs directly.  I am having problems with too much data going into excel and not in the right cells that I have named ranges for.  It seems like there is too much data being output to the MS office VI. 




Need more input. How are you getting the measurements? Is it a VI that returns a single measurement that you need to call 4 times, or is it a VI that returns an array with four measurements, or is it a VI that returns an array with a whole bunch of measurements, and you need to pull out 4 of them?

If you have a VI that returns a single measurement, like querying the marker value, you just need to put this in a for-loop that runs 4 times, and use auto-indexing to get yourself an array of 4 measurements. You can use the built-in "Mean" function to get your average of the values, and the "Array Max & Min" to get your maximum value. You didn't say how this MS Office VI takes these inputs, so it's not clear whether these are supposed to be bundled, or appended to the array.


0 Kudos
Message 3 of 6
(2,989 Views)
You do not need a Build Array or Index Array - that's what the loop's auto-indexing does for you. Also, there's a built-in Mean function:


As for the MS Office VI, I have no idea what VI you're referring to, if it's a built-in VI. If it's a VI that you or someone else coded, without knowing what its I/O panel is, I can't comment on how it's supposed to be wired up.

I would strongly recommend cracking open that LabVIEW Help book and going through the tutorials that discuss loops. Auto-indexing is a very fundamental operation in LabVIEW.

Message Edited by smercurio_fc on 05-07-2007 04:44 PM

0 Kudos
Message 4 of 6
(2,977 Views)
You could also do it without an array. Read the meter in a loop. Initialize a shift register to zero. Add the current reading to the previous value in the shift register and put the sum into the shift register. After the loop ends divide the output of the shift register by N.

Lynn
0 Kudos
Message 5 of 6
(2,957 Views)

All thanks for the help.  With everyones advice I built a small test vi to simulate what you guys said and it worked.  I will implement this into my code today.  I really appreciate what you guys have done.   Now I have to tackle the issue of the microsoft office VI problem.  That will be another post all by itself.  Thanks again.

 

 

 

0 Kudos
Message 6 of 6
(2,952 Views)