Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Sibin

Member

09-16-2014 02:19 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

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

Sibin K Mathew

Email: sibin.is.here@gmail.com

Mobile No:+1215-406-6545

http://in.linkedin.com/pub/sibin-mathew/48/846/446

Norbert_B

Proven Zealot

09-16-2014 03:00 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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:

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.

----------------------------------------------------------------------------------------------------

CEO: What exactly is stopping us from doing this?

Expert: Geometry

Marketing Manager: Just ignore it.

Norbert_B

Proven Zealot

09-16-2014 03:05 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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.

Norbert

Norbert

----------------------------------------------------------------------------------------------------

CEO: What exactly is stopping us from doing this?

Expert: Geometry

Marketing Manager: Just ignore it.

----------------------------------------------------------------------------------------------------

CEO: What exactly is stopping us from doing this?

Expert: Geometry

Marketing Manager: Just ignore it.

09-16-2014 03:30 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Norbert_B Thanks for the reply,

I am not sure you got my question right. I see your taking a set of 5 data and taking the average. But In my data ,i not sure of how many data is inside my tolerance .It can be 10,20 or even 1. so i need to find the set of that data and take their avg and mention the index from where it starts(min Index) and end(max Index).

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

Sibin K Mathew

Email: sibin.is.here@gmail.com

Mobile No:+1215-406-6545

http://in.linkedin.com/pub/sibin-mathew/48/846/446

P@Anand

Trusted Enthusiast

09-16-2014 03:42 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

The best solution is the one you find it by yourself

Norbert_B

Proven Zealot

09-16-2014 03:47 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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.

----------------------------------------------------------------------------------------------------

CEO: What exactly is stopping us from doing this?

Expert: Geometry

Marketing Manager: Just ignore it.

09-16-2014 03:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

Sibin K Mathew

Email: sibin.is.here@gmail.com

Mobile No:+1215-406-6545

http://in.linkedin.com/pub/sibin-mathew/48/846/446

Norbert_B

Proven Zealot

09-16-2014 04:19 AM - edited 09-16-2014 04:20 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

----------------------------------------------------------------------------------------------------

CEO: What exactly is stopping us from doing this?

Expert: Geometry

Marketing Manager: Just ignore it.