LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Group array data and avg them

Hi,

I have large set of data in an array and i want to group them to a particular value by averaging them and know their lower index and the max index of that particular avg value.With the tolerance setting ,say 5 for this example.The group of data need to avg and get the index of the frist value and the last value of the particular set of data

 

Group the array

 

i hope there is simple way to do this ?

With Regards

Sibin K Mathew



Email: sibin.is.here@gmail.com
Mobile No:+1215-406-6545
http://in.linkedin.com/pub/sibin-mathew/48/846/446
0 Kudos
Message 1 of 8
(3,888 Views)

The question is not necessarily "Can you do it?" but "What is the best approach in terms of performance?".

 

This is a first draft, which is, performance wise, not very elegant:

Average Array Segments.PNG

 

I say so as it deletes the segments from the original array which is a quite resource-intensive procedure and will fragment your memory.

But, it is easy code and it will do what you need.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 8
(3,874 Views)

And here another approach which should perform a little nicer in context of memory fragmentation (so less fragmentation). I also added Min/Max values. I don't create the clusters with Min/Max/Average value as array, that is something you can add.

 

Average Array Segments2.PNG

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 3 of 8
(3,872 Views)

With Regards

Sibin K Mathew



Email: sibin.is.here@gmail.com
Mobile No:+1215-406-6545
http://in.linkedin.com/pub/sibin-mathew/48/846/446
0 Kudos
Message 4 of 8
(3,860 Views)

In that case you can replace the constant "5" with a 1D array of tolerances. Will that work for you?

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 8
(3,851 Views)

Hm, i think i understand what you mean with "tolerance". That makes indeed things more complex.

Point is: How do you define "tolerance"?

 

Example:

Your array has value '1' at index 0. So a tolerance of 5 means, that any value <-4 or >6 in any following index is "out of tolerance" and therefore results in a new segment?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 8
(3,845 Views)

my idea was to take the first element and comapre with the next element.Is the value inside tolerance .taking my example in the fig .i take my frist data 1 that will write the min index =0 ,then i check with the next data 2 .is 2 inside the tolerance of 1+5/-5 ,if yes group that data with 1 by averaging .same to be done for the next value and so on. when the data reaches 15.Is 15 inside the tolerence of 1+5/-5 NO ,so the max index of the prev group (1's avg )is (present index-1)ie 4 as in example .And the min index of 15's data group is 5 .Now taking 15 ,doing the same as we did for 1st data. store all the set of data into cluster array  I guess this idea will work ,but not able to exectue this .need help in doing this.

With Regards

Sibin K Mathew



Email: sibin.is.here@gmail.com
Mobile No:+1215-406-6545
http://in.linkedin.com/pub/sibin-mathew/48/846/446
0 Kudos
Message 7 of 8
(3,842 Views)

I think, as modern PCs have a real high performing CPU, that you shouldn't focus too much on performance, but on code design.

I recommend you to create a flow chart or state diagram showing what your program has to do. Simple put: Transform your description into a diagram for code design.

 

Once you did that, you have to implement your diagram step-by-step in LV. If you chose the state diagram, a simple state machine would be the LV code architecture you would pick to implement your diagram with.

Remember to use shift registers for data you require in multiple states with the option to modify that data in single states.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 8 of 8
(3,833 Views)