LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete a "row" in an array?

I am relatively new to labview - still not completely used to thinking
in the style of labview's programming language...

My problem SEEMS like it should be a very simple one, but I am having
trouble implementing it.

I am trying to figure out how to delete individual "rows" in array.

I have a 2 dimensional array, and I want to delete certain entries in
one of the dimensions.

In other words, If I look at the 2D array as columns and rows, I know I
want to delete rows 1, 4, 9, 10, 17, etc...

Any help would be greatly appreciated!

Brent
fever@yuck.net
0 Kudos
Message 1 of 21
(9,293 Views)
> My problem SEEMS like it should be a very simple one, but I am having
> trouble implementing it.
>
> I am trying to figure out how to delete individual "rows" in array.
>
> I have a 2 dimensional array, and I want to delete certain entries in
> one of the dimensions.
>
> In other words, If I look at the 2D array as columns and rows, I know I
> want to delete rows 1, 4, 9, 10, 17, etc...
>

There isn't currently a node that makes this deletion trivial.
One way to do it is to use the Index Array node to select
rows or columns, and build-array or loop auto-indexing to
reconstruct a new array out of the remaining rows. You
may then have to Transpose the array depending on which
way the array is being sliced.

Greg McKaskle
0 Kudos
Message 2 of 21
(9,293 Views)
A small sample VI would be easy to comprehend for a beginner!

Your time is greatly appreciated.
0 Kudos
Message 5 of 21
(9,293 Views)
Brent Kirkwood wrote in message
news:jkNL3.551$b84.94377@ptah.visi.com...
> I have a 2 dimensional array, and I want to delete certain entries in
> one of the dimensions.

Brent
Your question could be understood in two ways, could you clarify what you
want to do?

(1). you want to set certain elements (e.g. all in a certain row) of your
array to zero, keeping the array size constant.
(2). You want a new array where e.g. 1 row is deleted, reducing the array
size by one in one of the dimensions.

For case (1), you just use "replace array element" in a for loop (transpose
and index as appropriate) and replace with zeroes.

For (2), you have to rebuilt the array without the desired rows. See Greg's
post for more detail.

Cheers
Christian
0 Kudos
Message 3 of 21
(9,293 Views)
What you can do is create a 1D array of rows you want to keep.
A = array of rows of interest
B = array to be operated on
C = new array
Wire array A and array B to the for loop, but disable autoindexing for
array B. Then use IndexArray VI with two indexes with column index
disabled. Wire element of array A (generated automatically by For loop
during autoindexing) to the IndexArray. Wire IndexArray output to the other
side of For loop, that will be array C.
Disadvantage is that now you have a second array and more memory is taken
up. With memory prices going up, boss might not be happy. I think that
memory manager might be smart enough to realize that array A is not needed
if you do not use it after the operation. Do not know for sure though.

Brent Kirkwood et> wrote in message
news:jkNL3.551$b84.94377@ptah.visi.com...
> I am relatively new to labview - still not completely used to thinking
> in the style of labview's programming language...
>
> My problem SEEMS like it should be a very simple one, but I am having
> trouble implementing it.
>
> I am trying to figure out how to delete individual "rows" in array.
>
> I have a 2 dimensional array, and I want to delete certain entries in
> one of the dimensions.
>
> In other words, If I look at the 2D array as columns and rows, I know I
> want to delete rows 1, 4, 9, 10, 17, etc...
>
> Any help would be greatly appreciated!
>
> Brent
> fever@yuck.net
0 Kudos
Message 4 of 21
(9,293 Views)
If you want to delete whole rows or columns, use the "Delete from Array" function.
Message 6 of 21
(9,293 Views)
This is not a direct answer, rather a slim hint wihtout prove!
0 Kudos
Message 7 of 21
(9,293 Views)
Fel,
The complexity of the solution to your problem is a direct function of what version of LabVIEW you are using. The newer versions include the function "Delete from Array", just as EH said, and this function does exactly what you want. However, in the older versions (e.g. 4.1) you had to code this function on your own. I attached a GIF picture that shows you how to use this function. Index "1" means that row 2 is deleted since LabVIEW start with index 0. If you want to delete columns, just wire to the column input instead. Now, if you have more than one row to delete, you need to keep track of the row numbers in your array since row 10 is row 9 once row 8 is deleted and so on.

I am going to give EH a four star rating for his answe
r since it was all correct. I hope this helps. /Mikael
Message 8 of 21
(9,293 Views)
Mikael,
Thanks for support!
I ought to eliminate certain rows from 2D array.
First I Loop For to select the unwanted rows in 1D array.
Second I Loop For to delete them wiring the Row terminal of the Delete Form Array with row # to delete minus 'i' and used Shift Register to remember the input and output Array.

Felix
0 Kudos
Message 9 of 21
(9,293 Views)

Another approach is to just index the array you want to delete from in a for loop and do your "keep or toss" evaluation within the loop.   Have another empty array feeding into the loop with a shift register.  As you test each row for the keep or toss criteria, feed the "empty" loop into a true/false case.  If you want to keep the row, add it to the empty array in the case.  If you want to toss the row, just wire the "empty" array straight through the case.

dudenohair_0-1650549582580.png

 

dudenohair_1-1650549644511.png

 

0 Kudos
Message 10 of 21
(3,212 Views)