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: 

deleting from array

Goal:
To create 3 randomly generated arrays, one representing an x-coordinate value, a y-coordinate value, and a height value.  All three arrays will have the indicies in common (i.e. if you are looking at index 5 of the height array, the corresponding x/y values will be located in index 5 of both arrays).  I want to be able then filter out the height values that are less than 15, along with their related x/y values.  So the only points that remain, are the points with a height greater than 15.
 
My approach has been...
1. Randomly generate 3 arrays
2. Search for height values >15
       A. If >15, append x/y values to new coordinate array
       B. If <15, append 0,0 values to new coordinate array
3. Search new coordinate array for 0,0 values, then delete
 
Problem:
For some reason... could be very simple, if there are two values that are read (back to back) as 0,0, then the program will fail to delete the index.  But if there is only one read, then the index will be successfully deleted.
 
If someone could help me out with this problem, or might have some other suggestions about how to solve the problem, that would be great.
 
 
0 Kudos
Message 1 of 4
(2,422 Views)

Don't jump through all these flaming hoops to do something this simple.. 😉

 

Message 2 of 4
(2,414 Views)
Sweet.  Thanks alot.  This looks much better than mine.
0 Kudos
Message 3 of 4
(2,402 Views)


@systems_eng wrote:
For some reason... could be very simple, if there are two values that are read (back to back) as 0,0, then the program will fail to delete the index.  But if there is only one read, then the index will be successfully deleted.
Just some additional comments:
  1. First, to explain the reason behind what you are seeing. You use [i] as index to determine which element to inspect and which element to delete.  Once you delete one element, all higher elements slide down one index. If the next element is again zero, it will be at the same index as the previous zero, but in the next iteration the index is one higher already. You never see the second zero! Insteat of the iteration terminal, you could use a shift register that is only incremented when you retain the current element.
  2. Look for coercion dots. Some of your diagram constants are EXT, some DBL, some I32, so ultimately everything must be coerced to EXT. There is no reason to use EXT, do everything in DBL.
  3. If an array does not get modified in the loop, it does not need to go into a shift register. Just use a plain non-indexing tunnel. However, if all you do is use index array wired to the iteration terminal as you do here, use an autoindexing tunnel. For example, the functionality of your original second loop can be reduced to the size of a postage stamp by using autoindexing (see image). The two versions are equivalent. 😄

Message Edited by altenbach on 07-08-2006 10:47 AM

Message Edited by altenbach on 07-08-2006 10:49 AM

0 Kudos
Message 4 of 4
(2,378 Views)