LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sort similar data into columns

I have a data set something liek this:

 

1 2 3 4 5

3 4 5

2 3 4 5

2 5

 

What I would like to be able to do is find a simple way of putting all the similar values into 1 column, like the following:

 

1 2 3 4 5

0 0 3 4 5

0 2 3 4 5

0 2 0 0 5

 

In my code I am not actually trying to match exact numbers, I am trying to put in columns numbers that are a few decimal places apart, so numbers like 5.1, 5.2 and 5.3 would be in a single column. Anyone know an easy way to do this?

0 Kudos
Message 1 of 11
(2,783 Views)

hi LVStudent,

  Are you reading any file or what?can you give some more details on your application?

 

 

Thanks and regards,

srikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 2 of 11
(2,777 Views)

In actual fact I have several graphs, each one varying slightly as they capture acoustic information at slightly different angles. With each graph they are quite similar however the peak position sometimes disappears or jumps slightly in either direction, or a new peak appears. This means when I represent the peak positions of each graph as a row in a 2d array,sometimes the peaks dont neatly line up in one colum. ie column 1 = peak 1, column 2 = peak 2 etc. If you refer to the description I gave you before you get an idea of what I mean.

0 Kudos
Message 3 of 11
(2,764 Views)
Umm, so I am guessing no one can help me out then?
0 Kudos
Message 4 of 11
(2,737 Views)

Hi LVStudent,

what have you done so far? How do you know the max size of the resulting array?

 

Mike

0 Kudos
Message 5 of 11
(2,726 Views)

This may be help you.

 

Modify Ref.Row constant as your need.

0 Kudos
Message 6 of 11
(2,715 Views)

If I have a 2d array where each row contains the values of peaks positions for a particular graph, then the max width of the array is the length of the array which contains the most peaks. As for the height, I have 360 graphs, so their are 360 rows. Basically I have 360 graphs, where each graph represents the acoustic reflection of an object at 1 degree increments. What I am trying to do is track the changes of specific peaks, however their position moves around a bit so I need a way of lining these peaks up again so I can do a useful analysis. So basically what I do is use the labview peak extractor on each signal, and store the peak positions for each angle in a 2d array. Now I just want to line the data up. For example peak 1 might start at bin 5, then in the next graph jump to bin 5.1 and so on. Peak 2 might start at bin 12 then might jump to bin 12.1, then 12.2. So then I should have something like follows.

 

5.1  12

5.2  12.1

5.3  12.2

 

However when I have data like this:

 

1 2 5.1 7     12

0 0 5.2 12.1

0 0 5.3 8     12.2

 

I am finding it diffult to work out a way to do this.I havent really got any code written for this either that you might be able to lookover, because I dontreally know where to start.

 

 

0 Kudos
Message 7 of 11
(2,713 Views)

If I have a 2d array where each row contains the values of peaks positions for a particular graph, then the max width of the array is the length of the array which contains the most peaks. As for the height, I have 360 graphs, so their are 360 rows. Basically I have 360 graphs, where each graph represents the acoustic reflection of an object at 1 degree increments. What I am trying to do is track the changes of specific peaks, however their position moves around a bit so I need a way of lining these peaks up again so I can do a useful analysis. So basically what I do is use the labview peak extractor on each signal, and store the peak positions for each angle in a 2d array. Now I just want to line the data up. For example peak 1 might start at bin 5, then in the next graph jump to bin 5.1 and so on. Peak 2 might start at bin 12 then might jump to bin 12.1, then 12.2. So then I should have something like follows.

 

5.1  12

5.2  12.1

5.3  12.2

 

However when I have data like this:

 

1 2 5.1 7     12

0 0 5.2 12.1

0 0 5.3 8     12.2

 

I am finding it diffult to work out a way to do this.I havent really got any code written for this either that you might be able to lookover, because I dontreally know where to start.

 

 

0 Kudos
Message 8 of 11
(2,702 Views)

Thanks Kumar for your code snippet, I think that may have almost solved my problem.

 

Cheers

0 Kudos
Message 9 of 11
(2,700 Views)

LVStudent wrote:

If I have a 2d array where each row contains the values of peaks positions for a particular graph, then the max width of the array is the length of the array which contains the most peaks. As for the height, I have 360 graphs, so their are 360 rows. Basically I have 360 graphs, where each graph represents the acoustic reflection of an object at 1 degree increments. What I am trying to do is track the changes of specific peaks, however their position moves around a bit so I need a way of lining these peaks up again so I can do a useful analysis. So basically what I do is use the labview peak extractor on each signal, and store the peak positions for each angle in a 2d array. Now I just want to line the data up. For example peak 1 might start at bin 5, then in the next graph jump to bin 5.1 and so on. Peak 2 might start at bin 12 then might jump to bin 12.1, then 12.2. So then I should have something like follows.

 

5.1  12

5.2  12.1

5.3  12.2

 

However when I have data like this:

 

1 2 5.1 7     12

0 0 5.2 12.1

0 0 5.3 8     12.2

 

I am finding it diffult to work out a way to do this.I havent really got any code written for this either that you might be able to lookover, because I dontreally know where to start.

 

 


The bit highlighted in red is the assumption you have made that is wrong. If the peaks are at different points you have a problem...

 

What you need to do is create a mega array of all the data points and find out how wide that would be:

e.g

1,2,4

1,2,4.5

these would still combine to make an array of 3 columns as all of the columns have the same data values.

1,2,3

1,2,4

these would combine to make an array of 4 columns (3 in IT speak and if indexing). The columns would be 1,2,3,4

 

If you have too much data to add together into 1 mega array and get the overall width first, the ther are other ways of doing it, I'm just pointing you at the simplest to implement. The other ways require more thought and debugging. (Think outside the box once you can see the problem).

 

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 10 of 11
(2,684 Views)