LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to gather array data in one column based on data in another column as reference?

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

4.901500.01
4.761500.02
4.611500.01
10.303000.06
10.343000.07
10.273000.07
5.141500.02
10.313000.06
4.951500.01

 

Please let me know if I can clarify a bit more. And thanks!

0 Kudos
Message 1 of 7
(3,330 Views)

Hello,

 

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.

 

Regards,

Adam

0 Kudos
Message 2 of 7
(3,322 Views)

Hi

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

Array Indexing.png

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 7
(3,312 Views)

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".

 

Spoiler
I felt I was being raped but I learned a lot!

 

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.

 

Silly me!

 

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

 

So...

 

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.

 

Have fun!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 7
(3,272 Views)

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?

0 Kudos
Message 5 of 7
(3,255 Views)

Just Provide the case value with 1..2 or 298..302

 Hope this will work for you

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 7
(3,249 Views)

Hello,

You can type 295..305 to refer to that range, however rounding the values also solves the problem.

 

Regards,

Adam

0 Kudos
Message 7 of 7
(3,248 Views)