05-29-2009 02:49 AM
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
05-29-2009 02:56 AM
Do you mean that the lines containing NaN must be deleted ? Is it possible to also have NaN in the other columns ?
05-29-2009 03:15 AM
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...
05-29-2009 03:20 AM
05-29-2009 04:05 AM
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.
05-29-2009 10:34 PM
hi krsone
can i hv the example for labview 8.0 plz..thk u
05-29-2009 10:38 PM
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
05-29-2009 11:46 PM
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:
...all these rules are quite different, but would produce the same correct result in your limited example. We need more information!
05-29-2009 11:47 PM
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.
05-30-2009 12:19 AM - edited 05-30-2009 12:23 AM
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.