03-08-2017 11:14 AM
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
Solved! Go to Solution.
03-08-2017 11:21 AM
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
03-08-2017 11:30 AM - edited 03-08-2017 11:31 AM
Like this?
And now how do i build the new array? (That's a Array Subset)
03-08-2017 11:38 AM - edited 03-08-2017 11:39 AM
No need for the Array Subset and you should be autoindexing the input array. Here is a less computationally intensive version.
03-08-2017 11:42 AM
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?
03-08-2017 11:48 AM
@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.... 😄
03-08-2017 11:53 AM
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.
03-08-2017 12:18 PM
@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
03-08-2017 02:23 PM
@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)
03-08-2017 02:28 PM
@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.