ODE45 error Inputs must be floats, namely single or double.
Mostrar comentarios más antiguos
I am trying to make a plot of conversion using a differential equation. I have divided up my work into two m files. The first is this
function dy = HWFOOL(t,y)
T = 300+200*y(1);
Kc = 10*exp(-6000/1.987*(1/450-1/T));
k = .01*exp((10000/1.987)*(1/300-1/T));
Fao = 0.2;
Cao = 0.1;
ra = -k*(Cao^2)*((1-y(1))^2-y(1)*Cao/Kc);
dy = sym(zeros(1,1));
dy(1) = -ra/Fao;
This runs fine and returns
ans =
(exp(1844508686086227/109951162777600 - 5533526058258681/(1099511627776*(200*y + 300)))*((y - 1)^2 - (y*exp(6640231269910417/989560464998400 - 6640231269910417/(2199023255552*(200*y + 300))))/100))/2000
My second m file, which should plot the conversion is
timerange = [0 10];
initial = [0];
[T,Y]=ode45(@HWFOOL,timerange,initial);
plot(t,Y(:,1),'-');
title('Conversion')
This returns
>> plotODE
Error using odearguments (line 110)
Inputs must be floats, namely single or double.
Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in plotODE (line 5)
[T,Y]=ode45(@HWFOOL,timerange,initial);
I have tried using matlabFunction after googling my problem, shown below
HWFL = matlabFunction(HWFOOL(t,y))
timerange = [0 10];
initial = [0];
[T,Y]=ode45(HWFL,timerange,initial);
plot(t,Y(:,1),'-');
title('Conversion')
Which returns
>> plotODE
HWFL =
@(y)exp((-5.032712632108706e3)./(y.*2.0e2+3.0e2)+1.677570877369569e1).*((y-1.0).^2-y.*exp((-3.019627579265224e3)./(y.*2.0e2+3.0e2)+6.710283509478275).*(1.0./1.0e2)).*5.0e-4
Error using
symengine>@(y)exp((-5.032712632108706e3)./(y.*2.0e2+3.0e2)+1.677570877369569e1).*((y-1.0).^2-y.*exp((-3.019627579265224e3)./(y.*2.0e2+3.0e2)+6.710283509478275).*(1.0./1.0e2)).*5.0e-4
Too many input arguments.
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 plotODE (line 6)
[T,Y]=ode45(HWFL,timerange,initial);
I'm not sure how to get this to work, and I am relatively new to matlab. Any help would be greatly appreciated
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Numeric Solvers en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!