MATLAB: Error using exp Too many input arguments.

indexode45

Hey guys, I want to solve a very simple ODE using ode45. However, there is a bug about exp, could you help me out thanks!
%The code is :
tspan = [0 1500];
y0 = 0;
[t,y] = ode45(@(t,y) exp(-0,0001/8.314./(300+4000.*y./(421.8-7.8.*y))), tspan, y0);
plot(t,y)
The feedback is :
>> aaa Error using exp Too many input arguments.
Error in @(t,y)exp(-0,0001/8.314./(300+4000.*y./(421.8-7.8.*y)))
Error in odearguments (line 87) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 113) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, …
Error in aaa (line 3) [t,y] = ode45(@(t,y) exp(-0,0001/8.314./(300+4000.*y./(421.8-7.8.*y))), tspan, y0);

Best Answer

The exp function doesn’t like the comma (,) as a decimal separator. Change it to a (.).
With that modification, this works:
tspan = [0 1500];
y0 = 0;
[t,y] = ode45(@(t,y) exp(-0.0001/8.314./(300+4000.*y./(421.8-7.8.*y))), tspan, y0);
plot(t,y)
Related Question