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.
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?
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.
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. 🙂
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. 🙂
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.