LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

remove items from 1-d array

Solved!
Go to solution

I'm trying to remove an element froma 1-d array usind the "delete from array" function.

I'm not sure why but the output is the same length as the original array with the element I was trying to delete - repplaced by a copy of another element.

 

Does anyone know why this happens?

 

Thanks

0 Kudos
Message 1 of 23
(3,260 Views)

Post your VI to show us what is happening.  It is difficult to debug a paragraph.

0 Kudos
Message 2 of 23
(3,258 Views)
0 Kudos
Message 3 of 23
(3,250 Views)

I cannot open your code because my LabVIEW 2009 version is too old, but here is a simple example of how to use the Delete From Array function:

 

code.png

 

results.png

 

Hopefully this may help you find your own error or at least learn a little more about the function 🙂

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 4 of 23
(3,244 Views)

I don't have your subVI, so I can't run your VI.  Also, what is some typical data?  Add typical data to the controls.  Run the VI.  Then go to Edit/Make Current Values Default before saving the VI.

 

The only spot I see using Delete from Array is right near the beginning.  When I put data in there, it seems to delete that item just fine.

0 Kudos
Message 5 of 23
(3,237 Views)

The "delete from array" used to remove an element from "used odors" appears to be fine.

I can't find another instance of delete from array ? Are you confusing it with "replace array subset" ?

 

0 Kudos
Message 6 of 23
(3,231 Views)

When I run it "Used odors" and the "array w/ subset deleted" are the same length.

The element that I tried deleting is just replaced with a second instance of the smallest number from "used odors".

0 Kudos
Message 7 of 23
(3,220 Views)

Here is the subVI.

 

Used odors is an array of a few (3-16) numbers. There are no repeating numbers in it.

"Target" is 1 member of "used odors". Im trying to get an array that has all numbers from "used odors" except from target"

0 Kudos
Message 8 of 23
(3,213 Views)

They will be if the 'target' value cannot be found in the "used odors" array.

In that case an invalid value of -1 will be passed to "delete from array" Smiley Wink

 

 

0 Kudos
Message 9 of 23
(3,212 Views)

You need to attach the VI with the data saved as default.  Perhaps there is something odd about your data.

 

What does the data look like?  Does the array need to be Doubles?  Or should it be integers?  Comparing doubles for equality can be a problem in computers, and that is that is happening at the heart of Search 1D array.  Put some probes on your wires leading up to Delete from Array to see what index it is trying to remove.

 

What happens if the target doesn't exist in the array?  It is not going to find anything and not going to delete anything.  But I dont' know why it would create second instance of the smallest number.

0 Kudos
Message 10 of 23
(3,209 Views)