function H = finitescarp(thetadegrees,a, x, kt ,bdegrees)

% Solves the finitescarp initial conditions problem for
%  thetadegrees is the initial scarp slope in degrees
%  a = half scarp initial height
%  x = distance along profile
%  kt = morphologic age (L^2)
%  bdegrees is far field slope in degrees
%  from Hanks, T. C. and D. J. Andrews, Effect of far-field slope on morphologic dating 
%    of scarplike landforms, Journal of Geophysical Research, 94, 565-573, 1989.

theta=rads(thetadegrees);
b=rads(bdegrees);
fkt=4.*kt;
sfkt=sqrt(fkt);
ang=theta-b;
A=a./ang;
X=x+A;
Xm=x-A;
H=-(ang.*sqrt((kt)/pi).*(exp(-((X.^2)./fkt))-exp(-((Xm.^2)./fkt)))+(ang/2).*(X.*erf(X./sfkt)-Xm .*erf(Xm./sfkt))+b.*x);

%--
function outrads = rads(indeg)

outrads = indeg.*pi/180;

