changeset 29397:ce425b657693 stable

fsolve.m: Fix undefined output error when using Output function (bug #60144). * fsolve.m: Define "output" structure and "fjac" output when solving is cut short by Output function.
author Jim Van Zandt <jim.vanzandt@gmail.com>
date Mon, 01 Mar 2021 09:45:56 -0800
parents 1f9e755bd91e
children a603c9fac000 69087119ee84
files scripts/optimization/fsolve.m
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/optimization/fsolve.m	Tue Feb 23 08:53:27 2021 -0800
+++ b/scripts/optimization/fsolve.m	Mon Mar 01 09:45:56 2021 -0800
@@ -255,6 +255,10 @@
     stop = outfcn (x, optimvalues, state);
     if (stop)
       info = -1;
+      output.iterations = niter;
+      output.successful = 0;
+      output.funcCount = nfev;
+      fjac = NaN;
       return;
     endif
   endif
@@ -430,6 +434,9 @@
         stop = outfcn (x, optimvalues, state);
         if (stop)
           info = -1;
+          output.iterations = niter;
+          output.successful = nsuciter;
+          output.funcCount = nfev;
           break;
         endif
       endif