diff --git a/matlab/trust_region.m b/matlab/trust_region.m
index 6b070d62bb12ddf170634b06882f8b7f2c00ac70..3e2396252daa68b7f3abdeec46ae5d7d49a31b0d 100644
--- a/matlab/trust_region.m
+++ b/matlab/trust_region.m
@@ -327,5 +327,9 @@ else
     end
     % Form the appropriate  convex combination of the Gauss-Newton direction and the
     % scaled gradient direction.
-    x = alpha*x + (1.0-alpha)*min(sgnorm, delta)*s;
+    if alpha>0
+        x = alpha*x + (1.0-alpha)*min(sgnorm, delta)*s;
+    else %prevent zero weight on Inf evaluating to NaN
+        x = min(sgnorm, delta)*s;
+    end
 end
\ No newline at end of file