LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does this array append code dosnt work?!

Solved!
Go to solution

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.

kurwa.png

why doesnt it work?

 

thanks

 

0 Kudos
Message 1 of 10
(1,447 Views)

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

Message 2 of 10
(1,439 Views)

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.


--Using LV8.2, 8.6, 2009, 2012--
Message 3 of 10
(1,437 Views)

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.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 4 of 10
(1,418 Views)

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, 

 

pic1.png

 

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

0 Kudos
Message 5 of 10
(1,397 Views)

Hope this is what you want.

original_edited.png


CLA CTAChampion
Subscribe to our Test Automation user group: UK Test Automation Group
Message 6 of 10
(1,385 Views)

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?

0 Kudos
Message 7 of 10
(1,383 Views)
Solution
Accepted by topic author spaaw

 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:BuildArray.png

 

Another option is to use a lossy queue with a lenght of 6 elements.

 

Ton 

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 8 of 10
(1,382 Views)

Please post a sample input array and what you want out of the code every iteration.

 


CLA CTAChampion
Subscribe to our Test Automation user group: UK Test Automation Group
0 Kudos
Message 9 of 10
(1,379 Views)

kkk thanks for your help, I appreciate it. Now I have enough info to go on. 

 

 

Regards,

spaaw

0 Kudos
Message 10 of 10
(1,372 Views)