LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I have used a 'for loop' to create an array of output data, however I want the each of the data sets from the array to be placed into a 1-D array. How do I concatenate the output of the for loop into a 1-D array?

I am using this to create a data set that will be passed as an anolog output therefore it needs to have the correct array dimensions to go into the analog write vi.
0 Kudos
Message 1 of 6
(3,395 Views)
As long as i understood you, you want every 1D array created in each iteration of the for loop to be concatenated to the next, so your best otion is to use a shift register, right click in one edge of the for loop, then select create shift register, and use build array function to concatenate every new array to the shift register value. Don't forget to initialize the shift register with an empty value and to change build array elements to arrays (both of them).
Hope this helps
Message 2 of 6
(3,395 Views)
If you are manipulating or creating each of the elements of the array inside the for loop, you can create a 1D array by wiring the wire with the elements to the edge of the For Loop and enabling indexing (Right-click connector in the edge of the For Loop and select "Enable Indexing") Then, you can concatenate this array to you existing 1-D array using the "Build Array" function. You may need to modify the inputs of this function.

Attached is a vi that demonstrate this. It is in LabVIEW 5.

Best Regards;
Vargas
www.vartortech.com
0 Kudos
Message 3 of 6
(3,395 Views)
Hi

I want to do somehing similar, so I thought you might be able to help. I've included my VI so you can follow along. Understanding the code on the left isn't necesssary, I don't think. I have successfully read two 1-D arrays (X and Y) from a data file, and performed a series of conversions on them, resulting in two new 'Converted' X and Y arrays. We only need to consider the X values here. What I want to do is separate these X values into those positive, and those negative, making a separate array for each. (I feel a sorting VI will not work, as the values must be maintained in order.) I have had some limited success, as you will see by running the VI. What I observe to be happening is that my VI doesn't insert each new X value into a ne
w element in its respective >0 or <0 array. Rather, it only allows 1 element in the array, always writing over what's previously in that element. If you notice, the values showing in the X > 0 and X < 0 indicators are exactly the last positive and negative X values read, respectively.

Is this simply a matter of a misplaced For-loop, or some other incorrect code? If you can offer any help, it would be much appreciated. Thanks!
0 Kudos
Message 5 of 6
(3,395 Views)
I'm updating my request... I've figured out how to do this by copying an example that uses a simple FOR loop (as seen in the attached current version of my VI). My question now becomes this: Is there a way to save the Y values corresponding to those X values into two more arrays? That is, just for argument's sake, let's say I took the first 100 elements from the X array, and found them to be positive. Then I would like to take the first 100 elements of the Y array and put them into a 'Y Values for X > 0' array. ...And likewise with the negative X values, they should have a separate array of corresponding 'Y values for X < 0' array.

I can see that I should somehow save the indices of the positive X values from the large arrray wh
en I sort them out, and use those indices to pick out the elements from the main Y array with the same indices.

I just can't seem to set up the code necessary to do this. ...Can anyone help, please?
Download All
0 Kudos
Message 6 of 6
(3,395 Views)
You can concatenate arrays using the "Build Array" function. Right click on the function and choose "Concatenate Inputs". Then you can concatenate two arrays together or even add in a single element to the array (if it is of the same type as what's already in the array).

If you are wondering about how to do it inside the for loop, you must either use a shift register with an empty, initialized array as the input, or just enable indexing on the output (right click on the tunnel and choose "enable indexing".
0 Kudos
Message 4 of 6
(3,395 Views)