MORECHEMISTRY.COM::MORE CHEMISTRY ON THE WEB    
Home Member Area Links Events Publications Promotions
#GOOGLELINKS#  

LabVIEW programming topics - arrays and loops

Using arrays (3)

This vi demonstrates how arrays can be manipulated with For Loops.

If a 1-dimensional array is connected to a 'for loop' then auto-indexing is on by default. The 'for loop' will treat the elements of the array one at the time. If you want to do some calculation on all the individual elements of the array it is okay to leave the N (number of iterations) unwired.
It is posible to pass the entire array to the for loop. This can be achieved by turning auto-indexing off. In this case N should be wired to the desired number of iterations.

Here are some cases of supplying an 8 element array as input to a 'for loop'.

case 1 - Auto-indexing is on, the scalar NumericValue 1 will be updated 4 times if Loopsize is 4 or 8 times if Loopsize is 12. The intermediate values will be visible.



case 2 - Auto-indexing is on, the scalar NumericValue 2 will be updated 4 times if Loopsize is 4 or 8 times if Loopsize is 12. The intermediate values will not be visible.



case 3 - Auto-indexing is on, the 1-dimensional array Array 1 will contain 4 elements if Loopsize is 4 or 8 elements if Loopsize is 12. The intermediate values will not be visible.



case 4 - Auto-indexing is off, the 1-dimensional array Array 2 will be recalculated, in its entirety, 4 times if Loopsize is 4 or 8 times if Loopsize is 12. The intermediate values will be visible.



case 5 - Auto-indexing is off, the 1-dimensional array Array 3 will be recalculated, in its entirety, 4 times if Loopsize is 4 or 8 times if Loopsize is 12. The intermediate values will not be visible.



case 6 - Auto-indexing is off, the 2-dimensional array Array 4 will be recalculated, in its entirety, 4 times if Loopsize is 4 or 8 times if Loopsize is 12. The intermediate values will not be visible.



Apparently turning auto-indexing on for 'inputs' will result in values of 1 dimension less whereas turning auto-indexing on for 'outputs' will result in values of 1 dimension more. Turning auto-indexing off will leave the dimension unaltered.

Downloads

array-loops.vi
The vi as described in the text.

See also...

- How to intialize and change the elements of an array.
- How to do basic array calculations.
Bart Boshuizen, 2005/03/08
#GOOGLEDISPLAY#
© copyright 2000-2014, morechemistry.com
design by Bb.