07-13-2016 02:42 AM
I am using an older version of LabVIEW (2010), and am having trouble gathering specific data from a 2D array. I would like to gather data in one column based on data values in another column, and send it to a seperate array.
Here's a small sample of data from my 2D array. Is it possible to have LabVIEW take all of the amp data for the 150 RPM and 300 RPM and sort it into two arrays? I can currently only do this using indexing, but that doesn't seem very practical in this case since the RPM data is mixed around.
APMS RPM LOAD
Please let me know if I can clarify a bit more. And thanks!
07-13-2016 03:09 AM - edited 07-13-2016 03:10 AM
You can use the array functions to reach your goal. First you have to get the 'RPM' column using Index Array VI, then use the Search 1D Array VI, to find the matches. To get all of the matches use a loop and a shift register. The shift register should contain the index of the last match, so it can be wired to the 'start index' input terminal of the Search 1D Array VI. Once you have the indexes, just use Index Array on the 'AMPS' column, to get the values.
You can even do the search of both 150 and 300 RPM in the same loop with a clever loop stop condition. Another way is just searching either 150 or 300 RPM and after indexing the values, deleting them from the original column. In the end only the rest 300/150 remain. Of course this only works if there are just 2 different RPM values.
07-13-2016 03:31 AM - edited 07-13-2016 03:33 AM
Code snippet Mapped is developed in LV 2015
If not able to access you can look into image and develop on your own environment
Create 3 cases (Default,150,300)
Simple Methods are available in Latest Version as you are using LV2010 you can follow attached Logic
07-13-2016 09:03 AM
It many and many a year ago in a VI written by me ... (See Anabelle Lee by Edgar Allen)
There used to be a series of presentations offered by NI hosted by Greg McKaskle called "The Good, The Bad, and the Ugly" where I offered up some code I developed for them to review. My intent was to get some pointers from THE EXPERT and I got exactly that when my code was chossen as "The Bad".
The code I offered was a utility I wrote to figure out "what happened to all of my disk space" back when my son was a teen and we shared a PC.
It would search a disk drive for all files in all folders and present a pie-chart starting at the top of the root of the drive showing how much storage was used by each folder. You could clcik on a slice of the pie and drill down into folders to explore the disk usage. But I am digressing...
In that code I implemented a "Bubble sort" to figure out how to generate the Pie Chart.
LabVIEw ahs the ability to sort arrays of clusters and if you set the cluster order correctly, it will sort on the first element of the cluster and then use the second element of the cluster to do tie-braking...
If you convert arrays to clusters and bundle them right, you can exploit the sorting of cluster to sort 2-D arrays.
It is a nice feature that I try to keep in mind any time I am faced with a "sorting" problem.
07-14-2016 01:53 AM
Thank you very much for you help. Your solution has worked beautifully. But I'd like to take it one step further. The RPM controler is not perfect, so some of the data values vary by 1 or 2 RPMs (e.g. 298-302 RPM). Is there a way to expand the range of accepted values in the case structure itself? Or must I round out the RPM data column first and then use that as a reference?
07-14-2016 02:39 AM
Just Provide the case value with 1..2 or 298..302
Hope this will work for you
07-14-2016 02:39 AM
You can type 295..305 to refer to that range, however rounding the values also solves the problem.