LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

deleting data from array

hi i need to delete this elements in array

 

example array i have:

 

123 abc 456

123 abc NaN

321 abc 654

321 abc NaN

 

red color elements need to removed.

 

the output should be like this:

123 abc 456

321 abc 654

 

how to do this..plz help

 

 

0 Kudos
Message 1 of 12
(7,087 Views)

Do you mean that the lines containing NaN must be deleted ? Is it possible to also have NaN in the other columns ?

0 Kudos
Message 2 of 12
(7,082 Views)

If you already know what lines to remove, just use delete from array.

Be careful, when deleting multiple lines in a loop using a shift register the line indices change when deleting a line...

 

 

Delete-from-array.PNG

0 Kudos
Message 3 of 12
(7,071 Views)
If you really need to remove lines with NaN data, see attached below...
0 Kudos
Message 4 of 12
(7,068 Views)

See image of BD for how the 2D array is passing in to the for-loop.

a. Shift in to the for-loop.
b. Pass in to the for-loop. This will auto-indexes each row of the 2D array at each iteration.

This portion of code checks every row for "NaN" regardless of its column...

Search the indexed row (1D array) with element "NaN".
If "NaN" is not found (index of element < 0), Case 'True', index=index+1
If "NaN" is found (index of element => 0), Case 'False', delete 1 row from the (shifted in) 2D array at current index value.

 

LVVILIB_ARR_2D remove found X value rows (String).GIF

Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 Kudos
Message 5 of 12
(7,056 Views)

hi krsone

can i hv the example for labview 8.0 plz..thk u

0 Kudos
Message 6 of 12
(7,020 Views)

hi

 

i dont want remove all the NaN elements in the array

 

 

example array i have:

 

123 abc 456

123 abc NaN

321 abc 654

321 abc NaN

523 cba NaN

456 baa 100

 

red color elements need to removed.

 

the output should be like this:

123 abc 456

321 abc 654

523 cba NaN

456 baa 100

 

how to do this..plz help

0 Kudos
Message 7 of 12
(7,018 Views)

jeyanthi wrote:

red color elements need to removed.


I assume that your 2D array of strings does not contain any color information, so you clearly need to be more specific how the program should detect a line to be deleted.

 

Lets look at the following random rules to detect deletion candidates:

 

  • [if second element is "abc" and third element NaN]
  • [if third element is NaN and second element is not "cba"]
  • [if third element is NaN and first element is either "123" or "321"]
  • [if third element is NaN and first element contains only digts 1..3 in any order]

 

...all these rules are quite different, but would produce the same correct result in your limited example. We need more information!

 

 

Message 8 of 12
(7,007 Views)

How do you want to tell LabVIEW which rows you want to remove?  LV has no idea what rows are "red".

 

The examples already given should tell you how to remove a specific row.  The only question is how do you want to tell LabVIEW what are the specific rows to remove?

 

If you define it has an array of indices,  in your case an array with the elements 1 and 3, that would correspond to indices 1 and 3 of the main array to remove.  I would reverse the array to make it 3, 1 and remove from the later elements first, that way you don't affect the index values of the earlier elements until you remove them.

Message 9 of 12
(7,005 Views)

First of all, it should be illegal to use "delete from array" inside a tight loop. It causes serious performance problems for larger arrays. (In the case of numerc arrays, I am not sure about arrays of strings). Typically, you want to do things "in place" as much as possible.

 

Here's a simple draft based on the example in the quoted thread. All you need to do is modify the detection algorithm and switch the case structure accordingly. So far it looks for NaN in the last column since you have not provided more specific instructions.

 

 

Message Edited by altenbach on 05-29-2009 10:23 PM
Download All
Message 10 of 12
(6,998 Views)