function [cross1,min1] = extract(x,u)

% want to find where the first derivative is most negative
y = diff(u)/(x(2)-x(1));
[a,i] = max(abs(y));

Y = y(i-2:i+2);
X = x(i-2:i+2);
PP = spline(X,Y);
dx = (max(X)-min(X))/1000;
xx = min(X):dx:max(X);
yy1 = ppval(PP,xx);
min1 = max(abs(yy1));

% want to find where the profile crosses the value alpha
y = u;
alpha = 1/2;
i = min(find(y<alpha))-1;
Y = y(i-2:i+2);
X = x(i-2:i+2);
PP = spline(X,Y);
dx = (max(X)-min(X))/1000;
xx = min(X):dx:max(X);
yy1 = ppval(PP,xx);
cross1 = find_thresh(xx,yy1,alpha);



