10-26-2012 04:56 PM
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 ?
Solved! Go to Solution.
10-26-2012 05:01 PM
10-26-2012 05:04 PM
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.
10-27-2012 07:39 AM
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.
10-27-2012 07:40 AM
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.
10-27-2012 09:25 AM - edited 10-27-2012 09:31 AM
You would build it inside the for loop, appending new data with each iteration as it is generated:
Here's a quick draft:
10-27-2012 09:54 AM - edited 10-27-2012 10:03 AM
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"
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.
Edit: If you have LabVIEW 2012 you can do this
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.
10-27-2012 10:44 AM
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 !
10-27-2012 10:53 AM - edited 10-27-2012 11:01 AM
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.
10-27-2012 11:00 AM
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.