취소
다음에 대한 결과 표시 
다음에 대한 검색 
다음을 의미합니까? 

remove items from 1-d array

해결 완료!
솔루션으로 이동

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 포인트
1/23 메시지
5,277 조회수

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

0 포인트
2/23 메시지
5,275 조회수
0 포인트
3/23 메시지
5,267 조회수

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 포인트
4/23 메시지
5,261 조회수

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 포인트
5/23 메시지
5,254 조회수

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 포인트
6/23 메시지
5,248 조회수

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 포인트
7/23 메시지
5,237 조회수

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 포인트
8/23 메시지
5,230 조회수

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" 윙크 이모티콘

 

 

0 포인트
9/23 메시지
5,229 조회수

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 포인트
10/23 메시지
5,226 조회수