LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

deleting data from a 2D array based on the id of the second column

Hello

I hope someone can help me. I have come across a hurdle in the programming of my application.

 

1.

I have a 2D array, the first column of this array contains my data and the second column contains an id, which is either 0 or 1.

 

I have sorted this 2D array based on the id column so that the data corresponding to the 0’s is on top part of the array and the data corresponding to the 1’s follows it (on the bottom of the array).

 

I want to delete that data (rows) of this sorted array that correspond to the 1’s and keep only the data (rows) that correspond to the 0’s.  

 

So I would end up with a new 2D array that has only the data that I want on the first column and 0’s on the second column.

 

I have hundreds of these 2D arrays resulting from my program (using a for loop) hence I want to automate this procedure. The length of the selected data arrays will vary.

 

2.

Once I can do this I will want to remove the id column (with the 0’s) from the 2D array and would like to build a new array with only the data from the first column (which may be of different length).

 

So I want to end up with a 2D array with columns corresponding to the selected (1st column) data from the (original) 2D arrays. These data may be of different lengths so when building this new array I may need to do some padding. Will labview do this automatically?

 

I hope that this is clear.

 

Best wishes,

0 Kudos
Message 1 of 3
(2,618 Views)
Attached is a different approach - you don't need to do any sorting.

The outer FOR loop assumes you have all the arrays available at once. If you are reading a file, modify it accordingly.

You may or may not want the TRANSPOSE function on the final results, depending on what you want to do with it.

Yes, when you assemble N-dimensional arrays into (N+1)-dimensional arrays, LabVIEW automatically pads for you.

Enjoy.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 3
(2,611 Views)

Thank you very much. That did it.

 

0 Kudos
Message 3 of 3
(2,585 Views)