MATLAB: Do I receive an error when specifying the Jacobian of a differential equation ODESET in MATLAB 7.4 (R2007a)

MATLAB

When I specify the Jacobian using the ODESET function and solve the differential equation as follows:
options = odeset('Jacobian', @vdp1000jac);
[T,Y] = ode15s('vdp1000',[0 3000],[2 0], options);
I receive the error
??? SWITCH expression must be a scalar or string constant.
Error in ==> odejacobian at 35
switch lower(joption)
Error in ==> ode15s at 291
[Jconstant,Jac,Jargs,Joptions] = ...

Best Answer

This error occurs when using a combination of strings and function handles to specify M-functions when solving ODE's. To work around this issue, use either only function handles or strings to specify the ODE function and the Jacobian function.
options = odeset('Jacobian', @vdp1000jac);
[T,Y] = ode15s(@vdp1000,[0 3000],[2 0], options);