Fixed problem with Matlab fsolve failing because of "user function returned Inf or Nan" (fsolve.m, line 245).