10-29-2014 01:52 AM - edited 10-29-2014 01:53 AM
Hi all,
I am using a for loop to get a pair of data from a 5000 x 2 array. The pair of data will change every second. However, after a period of time, I want the for loop to repeat, which means the pair of data should go back to row 1 of the 5000x2 array.
Can someone teach me how to do it?
Thank you and have a nice day.
VanessaWen
Solved! Go to Solution.
10-29-2014 02:40 AM
Hi Vanessa,
- when the number of iterations of your loop is NOT known when the loop starts you should use a WHILE loop!
- when you want to index arbitrary elements from your array(s) you should NOT use autoindexing but IndexArray!
- when you want to manipulate the "loop index" (aka use your own index) you should use a shift register holding your own index. Now you will be able to manipulate that index in any way you like…
10-29-2014 06:26 AM
10-29-2014 06:49 AM
Hi GerdW,
Thanks for suggesting a while loop. However, I do not understand the index part. Right now my goal is to extract different pairs of data from a 5000x2 array. I thought index array is for us to extract out the data in an array? After my while loop has finish extracting the 5000th row data, I want to extract the data from the first row and repeat the whole process again. This is an infinite data extraction loop until I want to stop it.
Is it possible?
A million thanks!
Regards,
VanessaWen
10-29-2014 07:39 AM
10-29-2014 07:39 AM
@VanessaWen wrote:
Is it possible?
Yes. You will want to keep your index in a shift register and increment it with each loop. After the increment, use Quotient & Remainder to divide the index by the array size. You will just want to keep the remainder.
10-29-2014 08:12 AM
Hi GerdW,
I have tried to modify my code. Now it works. However, everytime when the loop is going to restart, the 1st row of data can't be shown as the index "1" comes in slower than the clock rate. Can you suggest any solution?
By the way, number 5 indicates 5 rows of data. After 5 rowss of data are used, the loop should go back to 1st row of data.
Thanks!
VanessaWen
10-29-2014 09:47 AM
Well that would be the race condition caused by you mis-using a local variable and using a case structure where a Quotient and Remainder would be prefered
Why is Numeric is a DBL? Why is numeric is an indicator? Why is it on a Shift register?
10-29-2014 09:53 AM - edited 10-29-2014 09:54 AM
Jeff·Þ·Bohrer wrote: Why is it on a Shift register?
There's nothing wrong with it being in a shift register. I avoid using the "i" terminal just because it maxes out very quickly when dealing with FPGA. So you have to do it like this.
10-29-2014 09:59 AM
@crossrulz wrote:
Jeff·Þ·Bohrer wrote: Why is it on a Shift register?There's nothing wrong with it being in a shift register. I avoid using the "i" terminal just because it maxes out very quickly when dealing with FPGA. So you have to do it like this.
About every 68 years with that loop. Thats isn't too often and I'll be unavailable when it stops working