LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

appending 1d arrays of different length

Solved!
Go to solution

hi,

 

I have a set of 1d arrays of unequal length generated at the output of a FOR LOOP. They look like this:

 

array 1: 1 2 4 5 3 6 7 6 0 3 

array 2: 2 6 0 7 3 0 3 6 5

array 3: 9 2 6 1 7 9 4 0

etc.

 

How I can append them toghether so as to output the following 1d array:

1 2 4 5 3 6 7 6 0 3 2 6 4 7 3 0 3 6 5 9 2 6 1 7 9 4 0

 

Can any one help ?

0 Kudos
Message 1 of 11
(4,129 Views)
0 Kudos
Message 2 of 11
(4,127 Views)

If you're using LV 2012 use concatenating tunnels

 

Otherwise the easiest way is to use a Build Array inside the loop.  There are more sophisticated ways you should look into if your arrays are large.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 3 of 11
(4,125 Views)

Thank you elset191. The build array vi wont do the need. Because, in my case, 1d arrays are created by the FOR LOOP and the number of loop iterations are not preset. It changes with situations. It can be 5 or sometimes 13 or something different. So, I cannot fix the number of build array functions. I guess build array function is best if the number of 1d arrays for appending are known.

0 Kudos
Message 4 of 11
(4,091 Views)

Thanks Rod. The build array vi wont do the need. Because, in my case, 1d arrays are created by the FOR LOOP and the number of loop iterations are not preset. It changes with situations. It can be 5 or sometimes 13 or something different. So, I cannot fix the number of build array functions.

0 Kudos
Message 5 of 11
(4,090 Views)

You would build it inside the for loop, appending new data with each iteration as it is generated:

 

Here's a quick draft:

 

 

0 Kudos
Message 6 of 11
(4,077 Views)

Are you saying that your loop always produces three 1D arrays but the number of elements in each is variable, or are you saying that the number of 1D arrays is also variable?

 

Anyway if you have a known set of 1D arrays then just wire them to build array. In order to keep it a 1D array you have to select "Concatenate Inputs"

 

Build Array.png

 

If you have a varying number of arrays of varying length then you will want to look at a different data structure. The number of rows and columns in a 2D array have to be the same.

 

Something you could do is create a cluster that contains a 1D array. Then put that cluster into an array as well. Something like this.

 

Array of Array.PNG

 

Edit: If you have LabVIEW 2012 you can do this

 

Concatenating Tunnel.PNG

 

If that "array of array" data structure is something you need and would like it to be easier then you might want to give kudos to this idea

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Add-Support-for-Array-of-Array/idi-p/1875123

 

Edit: Or just build it as you go like Altenbach said if that is an option. Smiley Happy

=====================
LabVIEW 2012


Message 7 of 11
(4,071 Views)

Thank you Altenbach.

 

Let me explain:

I have a FOR LOOP that generates a sine pattern (1d sine data) in each iteration. The number of cycles are different in each case. Also, the number of iterations are variable. That means, both the array length as well as number of arrays are variable. I want to apend all these Sine samples. The output should be a continous stream of these sine data. Not an addition of amplitudes !

0 Kudos
Message 8 of 11
(4,058 Views)
Solution
Accepted by topic author kumban

My code does not do any "addition of amplitudes", whatever that may mean.

 

Here's ther same code appending sine patterns of different lenght, amplitude and # of cycles.

 

0 Kudos
Message 9 of 11
(4,052 Views)

kumban wrote:

I have a FOR LOOP that generates a sine pattern (1d sine data) in each iteration. The number of cycles are different in each case. Also, the number of iterations are variable. That means, both the array length as well as number of arrays are variable. I want to apend all these Sine samples. The output should be a continous stream of these sine data. Not an addition of amplitudes !


Why don't you show us some real code, it would make things much easier.

 

If the graph should update during the FOR loop, place the indicator inside the loop.

 

 

0 Kudos
Message 10 of 11
(4,044 Views)