I have defined a function that takes in 4 input parameters, and I want to be able to call it with either 3 or 4 arguments. If the 4th argument is not supplied, I want it to default to be an empty list [] .
However, right now when I call my function with 3 parameters, I get the error "Not enough input arguments".
I would like to call my function 'solver' in the following ways:
>> solver(h_odefun, tspan, y0)>> solver(h_odefun, tspan, y0, opts)
'solver' is defined as the following:
function [t, y] = solver(h_odefun, tspan, y0, options)[t,y] = ode45(h_odefun, tspan, y0, options);end
I would like 'options' to default to [] if the argument is not supplied.
Best Answer