01-23-2014 09:36 AM
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
Solved! Go to Solution.
01-23-2014 09:43 AM
Post your VI to show us what is happening. It is difficult to debug a paragraph.
01-23-2014 09:48 AM
Here's the code.
01-23-2014 09:53 AM
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:
Hopefully this may help you find your own error or at least learn a little more about the function 🙂
01-23-2014 09:55 AM
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.
01-23-2014 09:58 AM
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" ?
01-23-2014 10:02 AM
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".
01-23-2014 10:07 AM
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"
01-23-2014 10:08 AM
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"
01-23-2014 10:09 AM
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.