From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting only the odd rows of an array

Solved!
Go to solution

I have an array 120(rows)x160(columns).
I'd like to filter this array so that i get only the odd rows and i want to get an array of 60x160 in the end.
How can i do this?

I tried with "delete from array" and "Array Subset" but they allow me to get only a consecutive portion of the array, while here i want odd(or even) rows.

Thanks

0 Kudos
Message 1 of 17
(5,729 Views)

Use a For loop with indexed input tunnel and a conditional output tunnel.

The condition terminal should be driven from a "Equal zero" that comes from the remainded terminal of a Quotient Remainder that divides the iteration terminal by "2".

 

If I got the row column thing wrong use a transpose on the array before it goes to the For loop.

 

I do not have LV available to check so forgive me if I got that wrong.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 17
(5,727 Views)

Like this?
And now how do i build the new array? (That's a Array Subset)

0 Kudos
Message 3 of 17
(5,719 Views)
Solution
Accepted by topic author GianmarcoSbarra

No need for the Array Subset and you should be autoindexing the input array.  Here is a less computationally intensive version.


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 4 of 17
(5,696 Views)

crossrulz ha scritto:

No need for the Array Subset and you should be autoindexing the input array.  Here is a less computationally intensive version.


Doesn't this take out Single elements rather than rows? Am i missing something?

0 Kudos
Message 5 of 17
(5,687 Views)

@GianmarcoSbarra wrote:


Doesn't this take out Single elements rather than rows? Am i missing something?


Yes, you are missing something. On a 2D array input, it will take rows.

 

Instead of posting, just do the experiment! Probably faster.... 😄

0 Kudos
Message 6 of 17
(5,679 Views)

crossrulz ha scritto:

No need for the Array Subset and you should be autoindexing the input array.  Here is a less computationally intensive version.


Two days in a row that you solve my problems crossrulz, you're changeing the way i work with labview, thanks.

0 Kudos
Message 7 of 17
(5,666 Views)

@crossrulz wrote:

No need for the Array Subset and you should be autoindexing the input array.  Here is a less computationally intensive version.


Yes much more simple than what I attempted to describe and besides my version would have returned the even rows not the odd.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 17
(5,646 Views)

@Ben wrote:

more simple than what I attempted to describe and besides my version would have returned the even rows not the odd.

Ben


Tim's code also returns the even rows, but it is easy to fix. 😄

(e.g. initialize with TRUE or tap before the NOT to the conditional terminal)

Message 9 of 17
(5,623 Views)

@altenbach wrote:

@Ben wrote:

more simple than what I attempted to describe and besides my version would have returned the even rows not the odd.

Ben


Tim's code also returns the even rows, but it is easy to fix. 😄

(e.g. initialize with TRUE or tap before the NOT to the conditional terminal)


Depends on your definition of "even": Index is even or 2nd row (index=1) is even.  Mine with return the even indexes.  If that is wrong, just change the initialization to a TRUE.


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 10 of 17
(5,619 Views)