Jump to content

Initialize 2D array

Recommended Posts

I find surprising that the Initialize Array function doesn't allow for an array input. It would be really helpful for creating multidimensional arrays where not all elements are the same.

Of course the same can be done with a for loop, but doesn't feel so clean.




Link to post

QUOTE (Aitor Solar @ Jul 10 2008, 07:39 AM)

I find surprising that the Initialize Array function doesn't allow for an array input.

So you're trying to initialize a 2D array where each row is [0,1,2] - the change you're proposing would require the ability to select between rows and columns.

I don't find it surprising that functionality doesn't exist, as I've never seen a usecase for it. That said, if you do have one, let NI know as a feature request.

Link to post

How strange...yesterday, for the first time in my life, I attempted to wire an array to Initialize Array (and got a broken wire, and wondered why it wasn't allowed). Then I discovered this thread today...


Link to post

Sorry to go off topic (didn't feel that this deserved a seperate thread), but last week I realized that there is something missing from the basic I/O primatives. Why is there no GPIB query? It seems that this function should be available in a primative rather than having to be built up from a seperate read and write. I only have 6.0, 7.1, and 8.0 so maybe it has been added in a later version.

Link to post

QUOTE (Aristos Queue @ Jul 10 2008, 10:01 PM)

Here's another way you could do it that would be more efficient.

OK, so now I gotta ask, did you place the array outside the loop on purpose? The only difference I can see between the two methods is that the array is folded before the loop, but since the entire loop is folded, I assume that means that the array inside the loop is folded as well and therefore having the array outside the loop should not have any advantage.

Link to post

Well, the [0,1,2] array was just an example, obviously consecutive arrays can be generated easier but I was referring to any kind of array. Say you have a boolean array defining different properties of an object. You would like to generate n copies of the default configuration array for n objects in your application and treat them as a 2D array for easy comparison.

Sure this woundn't be a essential modification, since is the first time I have encountered this problem in all these years, but still it would be useful in some cases.



BTW, when testing if the initialize array function admits a cluster with an array inside (it does) I have discovered that if you take a waveform constant and try to duplicate the cluster elements inside the cluster, LV crashes. Funny.

Link to post

I do this kind of thing fairly often, so here are the VIs I've created for the purpose. I'm sitting at a Labview-less computer right now, so I can't check to see if these call any of my other VIs, but I don't think they do. Labview 8.5.1

Link to post
QUOTE (Yair @ Jul 11 2008, 04:52 AM)
OK, so now I gotta ask, did you place the array outside the loop on purpose?
Nope. In this case, inside or outside the loop would be the same. I was just posting the diagram where I had generated both to prove to myself that they really did output the same thing.
Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.