MATLAB: Do I receive an error when I try to pass in an input argument to the ODE solvers using an inline function

argumentserrorinline()MATLABode

The following code demonstrates this:
Tlim=[0 1]; Y0=[1];
odeqn=inline(' mu*Y' ,'t','Y','mu');
[t,Y]=ode23(odeqn,Tlim,Y0,[],2);
figure(1);
plot(t,Y,'-');
This is the error message:
??? Error using ==> inline/feval
Not enough inputs to inline function.
Error in ==> D:\Applications\Matlab\toolbox\matlab\funfun\private\odearguments.m
On line 104 ==> f0= feval(ode,t0,y0,args{:});
Error in ==> D:\Applications\Matlab\toolbox\matlab\funfun\ode23.m
On line 157 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ...

Best Answer

This error occurs due to compatibility problems between older versions of MATLAB 5.0 (R11) and newer versions of MATLAB, such as MATLAB 6.5 (R13). The usage of inline functions had to be backward compatible with MATLAB 5.0 sytax of ODE solvers, that is using the odefile. The old syntax for the derivative function was:
yp = odeeqn(t,y,flag,p1,...)
To obtain the compatibility, please change your code to:
odeqn = inline(' mu*Y', 't', 'Y', 'flag', 'mu');
instead of:
odeqn = inline(' mu*Y', 't', 'Y','mu');