LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
jdunham

Simpler "Array Size"

Status: New
The venerable Array Size function should just resize itself for the number of dimensions on the input array and have each dimension's size emitted with a separate scalar output.
14 Comments
GregSands
Active Participant
Better still to have the option of either scalar or array output - half the time I want one, and half the time the other.
jdunham
Member
Well I'm sure they would need the old one around for compatibility. I myself can't remember a single time when I glad to get the array sizes out as an array.
altenbach
Knight of NI

jdunham:

 

No, an array of dimensions is often useful, e.g. to get the total number of elements in a multidimensional array, you would apply a "multiply array element" to the array.

 

If you get each dimension individually, you need to rewrite the code whenever you want to change the number of dimensions.

 

There are plenty of examples in the forum, e.g.:

 

Example 1

Example 2 

 

Personally, I prefer the array. It is sufficient for me. 😄

 

jdunham
Member

But if you change from 1D to 2D you still need to change your code.  It's only if your code changes from 2D to 3D or higher that the size-as-array would 'help'.  If you're frequenly changing your diagrams between 3D and 4D arrays, then you've got other problemsSmiley Wink.

 

I would prefer to have a resizable Array Size function accompanied by the resizable Multiply (compound arithmetic) function, and have the diagram break if I were to change dimensions (like it does now between 1D and 2D).  And I'm sure they would have to keep the old one around for compatibility anyway.  

 

Thanks for the input!

Message Edited by jdunham on 06-01-2009 07:09 PM
Message Edited by jdunham on 06-01-2009 07:11 PM
GregSands
Active Participant

Other common uses that are much easier with array output are "array size - 1", or for evenly sub-sampling an array where you might divide the size by the scaling factor (I've done both of those!).  Looking through my reuse VIs, there's a fairly even split between using it as an array and as scalars - if the output was optional, then it could be an array even for 1D which would be consistent at least.

 

Ray.R
Knight of NI

When I read this I was thinking of an Array Dimension function.  I can't remember why or when I wish this function existed, but I do remember requiring that information during my LabVIEW travels.  The solution was simple by taking an array size of array size.

 

(I can never find the add attachments in the Ideas Exchange forum 😞 ) found it..  in the edit mode.

 

Something like below:

 

AristosQueue (NI)
NI Employee (retired)

RayR:

LabVIEW 2009\vi.lib\utility\VariantDataType\GetArrayInfo.vi

 

The VI takes a variant as input. Wire any array up to it (it'll coerce to a variant) and the subVI will return the dimensionality of the array.

Ray.R
Knight of NI

Thanks Aristos Queue.

 

I obviously still need to investigate all the nice little vi's in the libraries.  😉

 

 

Darren
Proven Zealot

Something I discovered a while back is that you can use the Matrix Size function to get the size of a 2D array of any data type without needing the extra Index Array to pull out the number of rows/number of columns separately.

 

-D

Jason_Harrigan
Member

jdunham, great idea on the resizeable funtion. The default, when sized to only one output, would be the array like it is now, and could take any sized input. When sized to two outputs, the input must be a 2D array, and the outputs are scalars. When sized to three outputs, the input must be a 3D array, with three output scalars, etc.