04-26-2010 10:35 PM
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?
04-26-2010 10:48 PM
04-26-2010 11:19 PM
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.
04-27-2010 03:08 AM
04-27-2010 03:46 AM
Hi LVStudent,
what have you done so far? How do you know the max size of the resulting array?
Mike
04-27-2010 04:14 AM
This may be help you.
Modify Ref.Row constant as your need.
04-27-2010 04:17 AM
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.
04-27-2010 04:37 AM
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.
04-27-2010 04:46 AM
Thanks Kumar for your code snippet, I think that may have almost solved my problem.
Cheers
04-27-2010 07:25 AM
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