03-11-2026 08:23 AM
Hi, im a little bit confused... I have a question with this basic function: Delete from array. (https://labviewwiki.org/wiki/Delete_From_Array_function)
if i understand correctly, I should get 20 elements in Array 2, correct? what did i miss?
Im using Labview 2025 Q1 (64-bit) 25.1.2f2.
Solved! Go to Solution.
03-11-2026 08:49 AM
You cannot delete more elements then are in the input array. There are at most 16 elements in the array before delete from array. The deleted portion will not be extended to the length parameter.
That is actually missing from the official help: https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/delete-from-array.html
03-11-2026 09:25 AM
I have tried with smaller numbers (2 or 4) but the output was just 1 element (84). I thought the output should be an array with length of 2 or 4, for my example?
@cordm wrote:
You cannot delete more elements then are in the input array. There are at most 16 elements in the array before delete from array. The deleted portion will not be extended to the length parameter.
That is actually missing from the official help: https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/delete-from-array.html
03-11-2026 10:04 AM
@Mystogan wrote:
I have tried with smaller numbers (2 or 4) but the output was just 1 element (84). I thought the output should be an array with length of 2 or 4, for my example?
Anything at index 15 or higher will be deleted from the array every iteration. Therefore, the array in the shift register will never be larger than 15 elements and so only 1 element will possibly be deleted from the array and output to Array 2.
03-11-2026 11:19 AM
You are deleting elements from the array as you are building the array.
You need to build the array first, then delete 20 elements from it.
03-11-2026 12:49 PM
@Mystogan wrote:
Hi, im a little bit confused... I have a question with this basic function: Delete from array. (https://labviewwiki.org/wiki/Delete_From_Array_function)
if i understand correctly, I should get 20 elements in Array 2, correct? what did i miss?
I assume this is a mockup code in order to understand the "delete from array" function and for that you seem to throw in several other code elements where you probably also need to get a deeper understanding first (shift register, prepending elements to an existing array (Always a bad idea!), "last value" output tunnels (the upper one is identical to the value you could get from the shift register output with much fewer wires and branches!), etc.).
This code is so convoluted that it is not even suitable as a CLAD question.
As a first step I would better isolate the "delete from array" and surround it with less confusing code and see how it behaves as a function of inputs (index in/out of range, etc.). As a second step, you should learn that "delete from array" should never (never ever!) be used in a tight loop. There are much more sane constructs that don't continuously hammer the memory manager. Delete from array did not even exist in very early LabVIEW versions and we managed just fine!
If this is actual code that you intend to implement in production, my advice would be "Don't"!. Maybe take a step back and tell us what you are trying to do, not how you are trying to do it. I am sure we can come up with something much simpler and more efficient.
I would also recommend to always quote the official help page for "delete from array" instead of the wiki, else you are potentially playing the telephone game.
03-11-2026 08:48 PM
@altenbach wrote:As a second step, you should learn that "delete from array" should never (never ever!) be used in a tight loop. There are much more sane constructs that don't continuously hammer the memory manager. Delete from array did not even exist in very early LabVIEW versions and we managed just fine!
One possible exception: getting the last element in the array. There was a stomping bug that got cleaned up sometime 10+ years ago, so now you can leave the index, length, and updated array output unwired and you will get an efficient way to get the last element of the array.
03-12-2026 01:21 AM
@crossrulz wrote:
One possible exception: getting the last element in the array. There was a stomping bug that got cleaned up sometime 10+ years ago, so now you can leave the index, length, and updated array output unwired and you will get an efficient way to get the last element of the array.
Yes there are always exceptions. When clipping the last element the remaining elements don't need to be touched.
(Still, it would not make much sense doing that over and over in a tight loop .... )
03-12-2026 09:04 AM
Thank you.
I’m working with code written by someone else, and I found this structure. In principle, the task is quite basic. Our goal is to collect a new measurement value in each iteration, store it in an array, and keep the last 20 values (that’s what I meant by “20” in the first picture). Then I want to calculate the average of those values.
Sorry, but the code I’m working with is quite confusing to me. Also, the value 15 (which in this case should actually be larger than 20, for example 50) is needed so that the array does not keep growing and consuming too much memory.
03-12-2026 09:38 AM
Take a look at Signal Processing >> Point by Point.
For your case you could use either Probability & Statistics >> Mean for just the mean value or Other Functions >> Data Queue if you need the array itself.