LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How does Array Subset work?

Please see attached vi. My objective is to output the items in column 3. The subarray should contain a 1D array consisting of 03, 13, 23, 33, 43, 53. As usual, the help file for this vi makes absolutely no sense. For the first index, it says

 

"index specifies the first element, row, column, or page to include in the portion of array you want to return...."

 

Since I'm drawing from a 2D array, this cannot be an element, and it's not a page, so it must be a row or column .. but which? row? I don't want ANY row. Column? I want column 3, length 6, but what do I enter in the other 2 indices? Same applies to index3. I believe I need to enter "column #3, length 6" but I don't know how. I could try all permutations & combinations of these 4 parameters until I get the desired result but that involves more programming than I want to do. Am I the only one who has trouble with NI's array help files? Can someone suggest what parameters to enter to achieve the desired results? I've already tried many logical approaches without the desired result.

0 Kudos
Message 1 of 11
(8,174 Views)
If you want the entire column, it's much simpler to just use the Index Array function and wire a single control to the column input.
0 Kudos
Message 2 of 11
(8,170 Views)
Agreed, it's much easier to use Index Array to peel off rows/columns. The thing you have to remember, and what's probably confusing you, is that Array Subset always returns an array with the same dimensions as the input array. Thus, even if you wire the indices and lengths so that you get a row/column, the result will still be a 2D array, albeit one that has one row or one column.
0 Kudos
Message 3 of 11
(8,162 Views)
You're absolutely right Dennis. But I still want to know what I'm missing in the Array Subset approach.
0 Kudos
Message 4 of 11
(8,160 Views)
And if you want to use the Array subset, you would use 0,6,3,1 as the parameters. Your statement that you don't want any rows does not make any sense if you want the entire column. To translate the parameters into something you might understand, 0 means start at row 0 and get 6 rows, start at column 3 and get only 1 column. Changing to 0,6,3,2 would get you the data in columns 3 and 4. all of these parameters can be based off of the Array Size function.
0 Kudos
Message 5 of 11
(8,154 Views)
smercurio and Dennis, thanks for the help. That's exactly what I needed to know, but was blatantly absent from the NI help file for Array Subset. It's unfortunate I have to go to this forum & trouble you people for information that should be in the help file. In the context of smercurio's input that the output array must have the same dimensions as the input array, Dennis' explanation makes sense. But the help file doesn't say that. it only says the subarray is of the same type as array, which means string, double, integer, etc. How would any LV user discern that valuable tidbit from the help file? Or  that the first 2 indices are looking for ROW information and not COLUMN information? Is there more complete documentation on these things you could direct me to?
0 Kudos
Message 6 of 11
(8,140 Views)

Well, the help says that "If you wire a 2D array to the function, the function displays the index inputs for a row and column, respectively." I interpret that to mean that the first index input is for the row and the second index input is for the column. I also interpret type to mean the same dimension(s) and not string/dbl/etc. Of course, I've been using this for a lot of years and know how it's supposed to work.Smiley Wink

0 Kudos
Message 7 of 11
(8,132 Views)

wb2nvy wrote:
smercurio and Dennis, thanks for the help. That's exactly what I needed to know, but was blatantly absent from the NI help file for Array Subset. It's unfortunate I have to go to this forum & trouble you people for information that should be in the help file. In the context of smercurio's input that the output array must have the same dimensions as the input array, Dennis' explanation makes sense. But the help file doesn't say that. it only says the subarray is of the same type as array, which means string, double, integer, etc. How would any LV user discern that valuable tidbit from the help file? Or  that the first 2 indices are looking for ROW information and not COLUMN information? Is there more complete documentation on these things you could direct me to?

 

Don't hesitate to post when the help is lacking.

 

The array operators where hard for me to get my head around at first. I rember the local NI sales type walking into our office as I was trying to learn how to use the array functions on a 3-d array and he rolled his eyes and went running for my bosses office since he was not going to ask about arrays.

 

As a general rule the indexes and size input are arranged from the last dimension that was added so it would be

 

Building

Floor

Isle

Shelf

Book

Page

line (row)

character (collumn)

 

if you were working with an 8D array (which is rediculous, I admit).

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 8 of 11
(8,130 Views)
Dennis, the help file you are quoting from would have been helpful to me. Here's the help file I was working from that isn't that explicit. Thanks for your support too, Ben.
0 Kudos
Message 9 of 11
(8,103 Views)

What version of LabVIEW are you using?

 

Dennis's post is the wording I see in LV 2009.  Looking at LV 8.6 I see less wording

 

Array Subset Details

You can use the Index Array function to determine the shape of the subarray you want to access or modify. For example, use the Index Array function to extract a 1D row from a 2D array.

 

 

 

That wording isn't present at all in the .pdf you posted.  So I'm guessing you are at LV 8.5 or earlier (I don't have the older versions on this PC to check.)

 

I'm guessing that over the versions, NI as improved the documentation a bit to help clarify those things that you were having an issue with.

 

Ben, Dennis,

Out of curiosity, what is the largest N for an N-dimension array you've ever used whether in LV or any programming language?  Would you ever have gotten to the shelf or aisle level?  What would come after building?  Street?

Message 10 of 11
(8,082 Views)