The documentation for decic has no explicit information about how many parameters the odefun takes. But it refers to the documentation for ode15i and that has an example that shows the undefined function @weissinger being invoked by both decic and ode15i, so the odefun for decic must that the same parameters as the odefun for ode15i . Which the ode15i documentation does not specify. But the documentation talking about the ode solvers says, in the description of the basic input arguments, that the form for odefun is dydt = odefun(t,y) . Therefore odefun must take two input parameters, and therefore decic must be called on a function with two input parameters. The counter-argument is that the place of the crash shows res = feval(odefun,t0,y0,yp0,varargin{:});
which implies odefun is being called with 3 arguments.
You are calling decic on "f", which you created via
f = daeFunction(DAEs, DAEvars, m, r, g);
but notice the comments after that indicating that
Hence when you are passing f to decic you are passing a symbolic expression. feval() is trying to convert that symbolic expression into a function handle, but there are 6 symbols in the symbolic expression so the function handle is being created with 6 parameters. But decic is only passing 3 parameters to it.
It appears to me that you should be passing F to decic instead of f.
Best Answer