LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get the number of elements in Array

Hi everyone,

 


Could anyone give me idea on how to get the number of elements in an Array (not number of rows) ?

 

I tried to find that in both property node and array functions but nothing.

 

 

Thanks,

 

-Kun

0 Kudos
Message 1 of 6
(16,788 Views)
The simple answer is Array Size. If you're dealing with a multidimensional array (which seems to be, based on your question), then this function will return an array. One element for each array dimension. To get the total number of elements, simply multiply the values of this array (Multiply Array Elements function) .
Message 2 of 6
(16,784 Views)

My array is a one-dimension one. 

 

I tried that 'Array size' functinon but it return some giant number.  Is there any other way to do it besides this?

0 Kudos
Message 3 of 6
(16,761 Views)

That giant number should be the number of elements in your array.  Are you looking for the number of non-zero elements or the number of elements that meet a certain criteria?

 

Maybe you could post your code?

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 4 of 6
(16,756 Views)

You are going to have to provide some proof that the Array Size does not work correctly. Right click on the input to it and select 'Create Indicator'. Run the VI. Go to the front panel and select 'Edit>Make Current Values Default'. Save the VI and attach it to your post.

 

You can also check the array size yourself. Right click on the index display of the array and select 'Advanced>Show Last Element'. I will bet you that number shown is equal to Array Size -1.

 

p.s. The number of elements in an array is equal to the number of rows in a 1D array. If you define the number of elements as anything else, you are mistaken.

Message Edited by Dennis Knutson on 04-21-2009 10:40 AM
Message 5 of 6
(16,753 Views)

Also don't forget that the array size depends on the data and is completely unrelated to the number of visible elements on the front panel.

 

Where does the array come from? What is the actual value of the "giant number"? Can you show us some code?

Message 6 of 6
(16,723 Views)