# HG changeset patch # User John W. Eaton # Date 1605711642 18000 # Wed Nov 18 10:00:42 2020 -0500 # Node ID 04f770eb264d36b6facc544e2f493ab6c3db38fc # Parent d8089b13d4d7fd4b8e79115bd40388cbb0720692 ode15s: create 3-argument wrapper around options.Events function (bug #59477) * ode15s.m: Create wrapper around options.Events function that accepts three arguments but ignores the third. Use two input arguments for feve event function in tests. diff --git a/scripts/ode/ode15s.m b/scripts/ode/ode15s.m --- a/scripts/ode/ode15s.m +++ b/scripts/ode/ode15s.m @@ -160,7 +160,13 @@ function varargout = ode15s (fun, trange endif options.Events = str2func (options.Events); endif - if (! is_function_handle (options.Events)) + ## The user-supplied Events function accepts two arguments but + ## __ode15__ will provide three. Create a wrapper that ignores the + ## third input to prevent an error about calling the function with + ## twoo many inputs. + if (is_function_handle (options.Events)) + options.Events = @(t, y, ~) options.Events (t, y); + else error ("Octave:invalid-input-arg", 'ode15s: "Events" must be a valid function handle'); endif @@ -433,7 +439,7 @@ endfunction %! refrob = [100, 0.617234887614937, 0.000006153591397, 0.382758958793666]; %!endfunction %! -%!function [val, isterminal, direction] = feve (t, y, ~) +%!function [val, isterminal, direction] = feve (t, y) %! isterminal = [0, 1]; %! if (t < 1e1) %! val = [-1, -2];