LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

auto increment fixed size of array having fixed elements where start index changes after every loop

I have a numeric data array of elements having data as {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}

which  increment index by 1 every time.

In the second loop i want the data in array as {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0}

in the third loop i want the data in array as {2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1}

in the fourth loop i want the data in array as {3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2}

in the same way this should happen till the last loop no 15th 

Please help to solve this problem.

 

0 Kudos
Message 1 of 4
(2,731 Views)

Hello, sukanya.sa,


I have attached .zip files where you can find solution fo your issue.

As I don't know what LV you are using I have made the second one for old LV version.

In the block diagram, you can find an explanation of the program.

Please feel free to ask if you still have questions.

__________________________________________
The best way to thank, is to give KUDOS
Download All
0 Kudos
Message 2 of 4
(2,669 Views)

use rotate 1D array in a loop.

 

arrayrotator.png

 

This example creates your input array on the left, then generates 16 different 1D arrays, one for each iteration of the second loop as required (red arrow shows where the current array is available). The output shows one row per iteration, verifying your requirements.

Message 3 of 4
(2,654 Views)

Optionally combine the Rotate 1D Array with a shift register:

Rotated Array.png

 

If the array is really large (kB), and you only want a small subset, something like this might work:

Rotated Array Subset.png

This could use some safeguarding, for instance a check for length > array size, index> array size-1, and so on.

 

This might not even be faster. The rotate could translate to a subarray wrapper (making the rotate almost 'virtual'), instead of an actual movement of memory. Benchmarking would be needed... Use the simple solution until it proves to be too slow.

0 Kudos
Message 4 of 4
(2,602 Views)