LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I'm having problems manipulating array data within a for loop, and extracting the required sub-arrays generated.

Hi,

I'm using labVIEW V5.1

I'm trying to generate 10 1D arrays, the first array is initialized to all zeroes, then I have set up a for loop which shifts the first element by 1, then a random number is placed into the first element position. I am using a shift register to feed back in the newly generated array into the start of the loop.

By the end of the each loop I want to be able to use the array generated in an algorithm outside the loop. However I only want the Nx1 array that has just been generated.
Unfortunately, I cannot figure out how to resize, reshape or index the output array to do this.

I would like the loop to
give me out a 1D array after each iteration.

Any help would be greatly appreciated.
0 Kudos
Message 1 of 4
(2,705 Views)
I just realised that another way around this problem would be to simply turn a 2D array into a 1D array, however every way I try this I still end up with a 2D output, please help cos I'm running late on a project,

Is there any way of specifying exactly what subset I want to take out to create my 1D array? It seems like a relatively simple task but I cannot figure it out.

thanks a lot for the help,
Jermaine.
0 Kudos
Message 2 of 4
(2,705 Views)
I hope I've understood your problem.
First your vi was lacking of the sub-vi working as shift register, I've replaced it with the rotate function.
The indexing of your arrays create a 2D array whose rows are your 1D array.To pick only one of them you have to use the index array function and select which one you want.
To use your temporary data in another part of your application you should use a local variable of array2.
I did it in a separated while loop That I syncronized with the for loop using occurrence, in this way the while loop runs each time a new value is inserted in array2 (each loop of the for loop structure).
If you don't need this syncronization just get rid of occurrence functions.
I place a delay in the for loop to show what happens when running.

Hope it was helpful.

Alberto Locatelli
Message 3 of 4
(2,705 Views)
Right-click on the black square that is the output of the for-loop. Choose "disable indexing". This should solve your problem. Good luck.

Martha
0 Kudos
Message 4 of 4
(2,705 Views)