LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compare sizes of many arrays

Solved!
Go to solution

BACKGROUND: I have made a program which takes 12 inputs and produces a particular motion in my motor based off all of those values. Now I want to be able to run a sequence of these specified motions, with different inputs.

 

I currently have a version where each of the 12 inputs are seperate arrays. So the program executes as for the scalar version with all the first elements, and then all the second elements etc. I achieve this somewhat neatly by building a 2D array from all the 1D arrays. The problem is that if the user forgets to input any cell, or one of the arrays is shorter or longer than another (due to user error), then the gaps are filled with zeros. This is really bad for my program.

 

One way I thought of preventing this was by checking that each input array is the same size and if they are not then throwing an error. It would also be OK if instead of the 2D array filling with zeros it could fill with the defualt value for each input array.

 

QUESTION: Is there an easy way to compare the sizes of many arrays?

compareArraySizes.PNG

Clearly this always returns true becuase when I build the array it fills in zeros wherever a cell was missing.

 

0 Kudos
Message 1 of 3
(3,225 Views)
Solution
Accepted by topic author da_winkel

I would say your data structure is wrong.  What you should do is have a cluster to contain all of the parameters for a single step.  Then you put that cluster into an array.  This gurantees you have a value for every parameter for every step and makes it easier down the line becaue you can use Unbundle By Name instead of having to index the right parameter and you keep the data type correct.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 3
(3,198 Views)

This is perfect! Exactly what I was looking for 😄 Thanks so much.

0 Kudos
Message 3 of 3
(3,178 Views)