Ok, I give up. So I'm seeking professional help.
I have data like:
x = [0.0, 0.1, 0.2, 0.4, 0.5, 0.8, 0.9, 1.0]
y1 = [1.0, 2.5, 2.0, 6.0, 5.5, 2.0, 0.5, 2.5] ;concave dn data
y2 = [5.0, 3.5, 4.0, 0.0, 0.5, 4.0, 5.5, 3.5] ;concave up data
What I want is to be able to "break" data such as y1 or y2 data
into 2 sets, array lefty to the left of the absolute maxima/minima
(greatest magnitude throughout the "function", not just local min/max)
and array righty to the right of the absolute min/max.
In both y1 and y2, the break should happen at x=0.4 (even though
there's other 1st deriv. sign changes at x = 0.1, 0.2, and 0.9).
The problem is that in y1, the break should occur at a maximum
point (y=6), in y2 it should be at a minimum point (y=0). So
whether I break at the max or min is dependant on the shape of the
data. Sometimes it should return all left and right of the max point,
sometimes the min point.
I'm not exacly sure how to proceed. Do you think that the best
action would be just to use the deriv(x,y) function to get the 1st
derivative numerically (so I can find where it's equal to 0), or
should I try to fit a polynomial, then differentiate that function
to get the 1st derivative? I guess I'm thinking along the lines of
finding where dy/dx=0, then try to decide if that point is an
absolute min/max. Then somehow deciding which I should break at,
min pt. or max pt.
Any suggestions? To get a visual, I've included a couple of
command lines below.
;:::
tek_color
x = [0.0, 0.1, 0.2, 0.4, 0.5, 0.8, 0.9, 1.0]
y1 = [1.0, 2.5, 2.0, 6.0, 5.5, 2.0, 0.5, 2.5] ;concave dn data
y2 = [5.0, 3.5, 4.0, 0.0, 0.5, 4.0, 5.5, 3.5] ;concave up data
plot, x,y1
oplot, x,y2, color=2
;:::
As you can see, it's easy to break both arrays into lefty and righty
visually, but to do it robustly in code, hmmmm....
Thanks in advance.
tb
|