LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D subset of 2D array

Solved!
Go to solution

Hello,

 

I have an array of two columns where each column is an array of 200K to 20M samples. I want to retrieve a 2D portion of this array starting at a specific index with a specific length. 

 

So for example if the array is

 

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

 

and I want to obtain the subset

 

[2, 3]

[9, 8]

 

I would (using my logic and the documentation) use the "array subset" function with index1=2, length1=2, index2=2, length2=2. But this at the end only returns an empty array, with a size of 0x2 (??).

 

Any tips about what I´m doing wrong?

0 Kudos
Message 1 of 11
(6,041 Views)

Your X index (the first one) needs to be 0, not 2, since that's the first row. You're asking for the third row, which doesn't exist.


___________________
Try to take over the world!
0 Kudos
Message 2 of 11
(6,020 Views)

If i set index1 to 0 and leave the rest as 2 I get an empty array with size 0x0

0 Kudos
Message 3 of 11
(5,999 Views)

Then you should upload an example, because from your description it sounds like it should work.

 

Edit - looking at your original post, you say that you have two columns, but your example shows two rows. If you do actually have two columns, then the Y index needs to be 0, not the X index.


___________________
Try to take over the world!
0 Kudos
Message 4 of 11
(5,976 Views)

Here is the test VI I am using. 

 

BTW I managed to get the results I wanted by creting a subVI with Array Indey and 1D Array subset funcitons (see attachment subset.jpg)

Download All
0 Kudos
Message 5 of 11
(5,943 Views)

Hi hun,

 

try this:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 11
(5,921 Views)

While this does what you want, you can do it much simpler. Try what tst suggested.



Remember Cunningham's Law
0 Kudos
Message 7 of 11
(5,915 Views)

Your example is also flawed.


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 8 of 11
(5,909 Views)

I suspect your Encoder Signal input array was flawed.  I ran your code, loading Encoder Array with 1,2,3, 4,5,6, 7,8,9 (3 by 3), then ran the snippet shown (I didn't wire in the default 0 for the two Index inputs), and got the 2 by 2 array 1,2, 4,5  as expected.

Array Subset.png

Bob Schor

Message 9 of 11
(5,902 Views)
Solution
Accepted by topic author thehun

I guess you are right that the input array must have some strange flaw. When I try with a short 2x10 array your solution works, but not with the default 2x350k array...very weird

0 Kudos
Message 10 of 11
(5,873 Views)