If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
comparing elements in array
3 posts
• Page 1 of 1
comparing elements in array
I'm looking for an efficent solution for finding a single "peak" value within a small array (less than 50 elements). While I could do this with greens - at 25fps and some other stuff going on - I think ruby may be faster on that. Here it is what I exactly look for.
Let say that I have an array of floats, like this:
121
90
77
66
51
30
37
43
51
43
36
22
10
In above example - the peak is at index 8.
Concept:
- peak is a value at index N, greater than values at N-1 and N+1 indexes
- there will be only a one single peak in such array
- border values (lowest and highest) are never a peak values
- peak value does not have to be "max" in array (otherwise - it would be simple)
- it has to be efficient calculation (25fps or more), thus parsing the whole array per each comparison should not be done by greens, rather ruby.
Let say that I have an array of floats, like this:
121
90
77
66
51
30
37
43
51
43
36
22
10
In above example - the peak is at index 8.
Concept:
- peak is a value at index N, greater than values at N-1 and N+1 indexes
- there will be only a one single peak in such array
- border values (lowest and highest) are never a peak values
- peak value does not have to be "max" in array (otherwise - it would be simple)
- it has to be efficient calculation (25fps or more), thus parsing the whole array per each comparison should not be done by greens, rather ruby.
Last edited by tester on Fri Mar 28, 2014 12:39 am, edited 1 time in total.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: comparing elements in array
It is called local maximum. No ruby needed...
- Attachments
-
- local maximum.fsm
- (878 Bytes) Downloaded 731 times
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: comparing elements in array
Thanks, I did not knew that it's possible that way.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 77 guests