How can I find Max and Mins of array by seeing which point's derivative is closest to 0 [message #61602] |
Tue, 22 July 2008 11:27 |
lukedimperio
Messages: 1 Registered: July 2008
|
Junior Member |
|
|
Fellow programmers,
I have produce several ~ shaped plots in IDL and would like to
find the Max and Min of the crest and trough respectively. Yet, the
points of the ~ reach above and below the tops and bottoms of the
curves trough and crest. So I thought I would locate them by find
where the derivative of the curve equalled zero, right? Yet, it was an
array so the wasn't an exact 0. So, I figured I would attempt to find
the minimum of all the positive array slopes(derivatives) and this
would be a point right after a minimum or before a maximum. Or you
could do it by finding the maximum of all the negative array slopes
and that would correspond to a point just before a minimum or right
after a maximum. It didn't really matter if I was off by one point
because there were so many points in the array. Here's the fun part
though; I tried several different lines of codes mostly include where
commands finding each time the max and min would be at the end and NOT
at the top of the crest or bottom of the trough like I wanted them to
be!
In case the squiggles aren't visible enough the plot is a fit by a 3rd
order polynomial, sort of like a sideways s. Not really this S though
because doesn't really look like a function.
Anyway, please help and please feel free to email me
lukedimperio@yahoo.com
Luke D'Imperio
SUNY Oneonta
P.S. I'm getting suspicious of a invisible zero at the beginning of
the curve. Don't let it bother you too much though.
|
|
|