LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

re-arranging array elements

Hello,
I have a 2D array that has duplicate values, i've been trying to rearrange the elements based on first column. Here is an example of the data.
Input array : A            20              output array : 20    10      30    
                    A              5                                       5     7       10 
                    A             15                                     15     
                    B             10
                    B               7
                    C              30  
                    C              10



The idea is, to find all the values for an element in first column and place those values in a new column.
later on to use this new array to calculate stdev.  
Any help would be very much appreciated.
0 Kudos
Message 1 of 8
(4,230 Views)
You can only make a meaningful 2D array if all columns will have the same number of data values. If not, the shorter columns will get padded, potentially messing with your averaging calculation.
 
Since you seem to have a 2D array of strings, the pading can be done with "empty strings" and you can treat this as an exception when averaging.
 
Why do you even need to place the values in new columns first? Maybe you can do the averaging without creating a new 2D array? What is your LabVIEW version?
0 Kudos
Message 2 of 8
(4,224 Views)
Thanks for the quick  response.
I'm using LV 7.1 for Linux. The reason i'm placing the values in new columns is because i didn't know a better way to calculate stdev with out regrouping the values.
0 Kudos
Message 3 of 8
(4,222 Views)
Here's a simple example that averages the corresponding values of the second colum for each unique value in the first column. (LabVIEW 7.1). Let me know if this makes sense. 🙂
 
It assumes that the first column is sorted.
 

Message Edited by altenbach on 09-10-2006 09:55 AM

Message 4 of 8
(4,220 Views)
The above assumed that the first column is sorted as in your given data example. If it is not, you need to sort the column first before extracting the unique elements, of course. 🙂
 
 
Message 5 of 8
(4,216 Views)
It works perfect for averaging. But  I was trying to do standard deviation using the LV function, which takes a 1D array as an input.  i think i can modify your code to get it to work for standard deviation. Thank you very much for your help.
0 Kudos
Message 6 of 8
(4,213 Views)
Message 7 of 8
(4,206 Views)
This is perfect. It's exactly the way i wanted it.
Thanks a million.
0 Kudos
Message 8 of 8
(4,198 Views)