LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Logical question, it's not enought to know LabVIEW, it's necessary intelligence...

Dennis's solution will give you the last 5 random numbers but the order will not be preserved. You would need to use a array subset and a build array to preserve the order of the elements.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 21 of 97
(2,966 Views)

No you don't.  There's a really simple way to do this but I'm not saying.

 

Shane.

Message 22 of 97
(2,950 Views)

Hint: look again at post #5...

 

Message 23 of 97
(2,946 Views)
Shift register.
Message 24 of 97
(2,942 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 25 of 97
(2,929 Views)

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.

 

Message 26 of 97
(2,909 Views)

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.

Message 27 of 97
(2,905 Views)

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.

Message Edited by Hornless.Rhino on 25-02-2010 11:30 AM
Message 28 of 97
(2,895 Views)
Example of lossy queue. The op did not mention what is supposed to be done to the oldest data.
Message 29 of 97
(2,887 Views)

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.

Message Edited by DianeS on 02-24-2010 06:56 PM
Message Edited by DianeS on 02-24-2010 07:01 PM
Message 30 of 97
(2,876 Views)