12-18-2009 01:20 PM
Hi,
I am wondering how best to manipulate arrays. I have multiple arrays which will grow over time. Once I reach a size limit I want to keep adding the most recent data to the end of the array and lose the older data at the start of the array.
It seems simple enough but I'm wondering what is best practice. I can think of two options:
Is one any more efficient than the other?
I seem to remeber that reversing an array is a very efficient process, but I'm unsure about rotating.
Thanks in advance for any insights.
Ian
(LV 8.5)
12-18-2009 01:34 PM
Hi Ian,
I would avoid the option with the build array function as this requires the use of the memory manager. The replace array subsest is usually the best option. You mentioned the array growing, would it be possible to pre-initialise it?
Also it seems like you are implementing a lossy FIFO here, have you thougt about a RT FIFO (always fixed length and lossy) or a fixed length queue? Both of these options will implement the same behaviour.
Regards,
Steve.
12-18-2009 01:50 PM
The "most effiecient array handling" is done in-place.
See this tag and its related links.
Post follow-up question if those don't answer your questions.
Ben
12-18-2009 02:40 PM
Thank you Steve and Ben,
A fixed size array makes a lot of sense now I think about it.
Yes, I'm trying for a FIFO but I want to fill up my array first. My end goal is to have multiple arrays plotted onto a single graph to represent the data that I am collecting from my hardware. The more data plotted on the graph the better. There will eventually be a point at which a practical limit is imposed on the size of the arrays, which is when I want to start deleting the older data.
Using sets of fixed length arrays would work for me. I would just have to manipulate my graph to show only the data that I want to be seeing. I think I need to run some tests comparing fixed arrays and graph property nodes against resizing arrays and straightforward graphing.
All the best,
Ian
12-18-2009 02:54 PM
_Ian_ wrote:...
I would just have to manipulate my graph to show only the data that I want to be seeing. ...
All the best,
Ian
Hint:
The value "NaN" when presented to a graph or chart will NOT plot a point.
Ben
12-18-2009 03:07 PM
That should save me a bit of work.
I was about to ask how to initialise an array of NaN - but a quick search revealed its as easy as typing NaN into a numeric constant!
Thanks for your help - I'm good to go.
Ian