LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For loop arrays

Is there any way to get rid of the first value that the for loop puts into the auto indexed array? I am taking the average of the array elements but the first element is always invalid. Can I get rid of the first element before or after the array is created?
0 Kudos
Message 1 of 9
(3,689 Views)
You could use the array subset vi.
----
I am the founder of CnCSoftwareSolutions. When not cleaning up baby drool, I write about test data or work on Vision, a tool for understanding your test data. Visit me at www.cncsoftwaresolutions.com
Message 2 of 9
(3,679 Views)
You could also built your array in a shift register and have the built array node in a case structure that is only ON when desired.
Message 3 of 9
(3,673 Views)

I was just wondering..By invalid do you mean the first element is not a number or you just want to ignore the first element while calculating the average..in any case you can still use the Array subset vi.

-Prashant.

0 Kudos
Message 4 of 9
(3,671 Views)
I mean that the first number for some reason is an off reading...and I dont have time to find out why so I would much rather ignore it. Thanks for the help Fellas.
0 Kudos
Message 5 of 9
(3,670 Views)
Here's an example showing three possibilities to skip element # zero (LabVIEW 7.0):
 
 
Message 6 of 9
(3,665 Views)
For bonus points (and to help me learn)...
What are the advantages of each method Altenbach?
----
I am the founder of CnCSoftwareSolutions. When not cleaning up baby drool, I write about test data or work on Vision, a tool for understanding your test data. Visit me at www.cncsoftwaresolutions.com
0 Kudos
Message 7 of 9
(3,654 Views)
"Trimmed" is the easiest.  Easiest to wire.  Easiest to read.  A little wasteful, because you created one more value than you actually needed.  However, you do not need to know a piori how many instances you need.

"Built" is the least efficient in memory and speed.  You will not notice much of a difference in such a small array, but you will get killed in larger ones.  It does have a small advantage in not using the invalid first datum.  Similar to "trimmed", you do not need to know ahead of time how many data values are involved.

"Replaced" is the most memory and speed effienct.  You do have to know exactly how big an array to build beforehand.
Message 8 of 9
(3,647 Views)
Well, the top method would get complicated very quickly once you want to drop random element positions. 😉
 
The other two methods depend a bit on the circumstances:
 
The middle method is simple and "good enough" for small arrays. It is preferred if the output array is only very small (i.e. only a small percentage of elements are kept)
The bottom method is probably most efficient for very large arrays. It would need to be modified a bit for random element skips. Easiest would be to allocate the same size as N of the loop, then trim the output to the size of the lower (blue) shift register after the loop.
 
If this is critical code, you should test various version and see which one is best for your particular scenario.
Message 9 of 9
(3,643 Views)