02-24-2010 05:18 PM
02-24-2010 05:43 PM
No you don't. There's a really simple way to do this but I'm not saying.
Shane.
02-24-2010 05:45 PM
Hint: look again at post #5...
02-24-2010 05:48 PM
02-24-2010 06:09 PM
dan_u wrote:Hint: look again at post #5...
While that will work after the fact, it will not keep the working array at a fixed sized. For small arrays this isn't an issue but if you will not terminate the loop until a significant number of iterations you could run into memory and performance issues. The split and build could use in place memeory and be more efficient for large arrays.
02-24-2010 06:18 PM
Mark Yedinak wrote:
dan_u wrote:Hint: look again at post #5...
While that will work after the fact, it will not keep the working array at a fixed sized. For small arrays this isn't an issue but if you will not terminate the loop until a significant number of iterations you could run into memory and performance issues. The split and build could use in place memeory and be more efficient for large arrays.
Rotating an array and replacing array elements are both very efficient methods to manipulate an array. Which of these functions will change the array size? None I guess.
I just wanted to give some directions, not the full solution. Of course the mentioned elements have to be used together with a shift register which has been initialized with an array of the correct size.
02-24-2010 06:19 PM
Now I think I understand better what the question was.
How about a fixed size queue? That would preserve the size and new numbers would be placed at the end.
02-24-2010 06:30 PM - edited 02-24-2010 06:30 PM
Dennis Knutson wrote:Now I think I understand better what the question was.
How about a fixed size queue? That would preserve the size and new numbers would be placed at the end.
A queue is FIFO too, soyou might be onto something there.
02-24-2010 06:32 PM
02-24-2010 06:52 PM - edited 02-24-2010 07:01 PM
The lossy queue is a great solution, Dennis!
It can also be done using the array functions, with a combination of "delete from array" and "insert into array" (after the inital array population -- if the loop iterates fewer than 5 times, you have to account for that too). You just have to delete and insert the correct elements. That will preserve the array size, and output a 5-element array containing the last 5 values generated...the final value generated is element 0, the next-to-final element generated is element 1, etc.
I scribbled up a little VI that seems to do the trick.