function L = tanhfit(x,dat_temp)

% This function fits a hyperbolic tangent to the germination data

high = x(1);
low = x(2);
alpha = x(3);
beta = x(4);

xobs = dat_temp(:,1);
yobs = dat_temp(:,2);
ymod = low + (high-low)*(0.5*(tanh(alpha*xobs - beta)+1));

[high low alpha beta]
L = sum((ymod - yobs).^2)
