01-20-2012 03:45 PM
Im bringing in an array into the for loop, i take 2 elements from that array and then I want to create an array with 3 times 2 elements.. for example, if the array = 1 and 2 three times in a row i want it to be 1, 2, 1, 2, 1, 2. What I have now is being overwritten.
why doesnt it work?
thanks
Solved! Go to Solution.
01-20-2012 04:05 PM - edited 01-20-2012 04:05 PM
Your VI does not overwrite anything. It just keeps making the array bigger.
It also seems to do just what you asked.
Please post again with data saved in the Particle Measurements array and something showing exactly what you want the output to be. Or post an image of the input array.
It would be better if every element of the input array was unique. That way we can be sure that each element goes where you want it.
Index Array may be better than converting to a cluster.
Lynn
01-20-2012 04:07 PM
You should take a look at some of the Array functions. Reshape Array might do what you want without all the mess. You definitely don't need to convert your array to a cluster to get the values out. You say you want a 3x2 array, but your Array indicator is 1 dimensional. The Build Array is appending, not creating dimensions.
01-20-2012 06:17 PM
Please enter typical data into the controls and make the new values the default before creating a snippet. All we get is an empty array and the desciption: "the array = 1 and 2 three times in a row" is not clear at all considering that we start with a 2D array and you don't even mention columns.
Is the input 2D array
1 2
1 2
1 2 or
1 1 1
2 2 2 or something else?
Tell us the exact input you have and the exact result you expect to get.
As others have said, nothing gets overwritten as you claim.
[1, 2, 1, 2, 1, 2] is NOT a 3x2 2D array. but a size=6 1D array.
You post makes no sense at all.
01-21-2012 09:13 AM - edited 01-21-2012 09:15 AM
sorry i wasnt clear, im starting with a 2d array, im extracting 2 elements from it every time the vi is called. The 2 elements are random. For the final result, id like to have a 1d array with 6 elements that were extraced over the period of 3 calls.
here is an example,
this snippet is giving me repeated values whereas I want 6 different elements in the 1d array output. I dont wanna use while loops.
any ideas?
thanks
01-21-2012 09:57 AM
01-21-2012 10:01 AM
thanks.. how can i change that so that the array will update when my VI is called? I need to get 2 elemens each call. Do you know?
01-21-2012 10:02 AM
If you want to have a memory inside your function than you should not create an input to the shift register.
What you want can be found in the 'point-by-point' palette, look for the functionality 'Data Queue PtByPt.vi', this holds an internal array of predefined lenght. Since you want to add two elements per call, I'd suggest to put it in a for loop:
Another option is to use a lossy queue with a lenght of 6 elements.
Ton
01-21-2012 10:17 AM
Please post a sample input array and what you want out of the code every iteration.
01-21-2012 10:39 AM
kkk thanks for your help, I appreciate it. Now I have enough info to go on.
Regards,
spaaw