VI High 31: How to Create & Manipulate Multi-Dimension Arrays with LabVIEW For Loops
This episode is part of a VI High series focusing on arrays that runs from VI High 24-32.
In VI High 29 we started learning about auto-indexing arrays, but we kept them limited to 1D arrays. In this episode we’ll learn about creating and manipulating 2D arrays through nested For Loops.
For more LabVIEW training check out http://www.sixclear.com.
You can also keep up with us at:
http://twitter.com/#!/sixclear
Experience level: Basic
(start transcription)
So far I’ve kept it simple and done a 1-D array. But how to create or manipulate a 2-D array? or a higher dimension array? That’s pretty easy too.
Let’s go back to my Random Number Generator, wrap it in a For Loop as before, and then wrap it in another For Loop. So they’re nested. Wire this out to the border of the outer loop, Create an Indicator, and there we are. We have a 2-D array.
I need to tell LabVIEW how big to make this, so let’s say I put in four and six. Run it, and there we go. Six rows, and four columns. So here’s my row. Here’s my column. And you can guess, if I made a copy of this, changed it to a control, and wired it into two nested For Loops, that Auto-Indexing would take over, both loops would know how many times to run, and that would go one by one and access scalar elements in this array.
Let’s take a look. Highlight Execution. And one by one, we see each individual element being accessed across the top, then the next row, and so on. This wire right here would be the row we’re accessing. Of course, the inner wire is the scalar.
Well, that was fun. I agree. But did you get confused at all with the indexing, especially the inputs?
Well, if you’re taking the CLAD exam, it’s a common topic, and next time, we’ll expand a bit more on Auto-Indexing inputs, and how many times a loop runs, and what will be the resulting output. So come on back.
(end transcription)