Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Need help with differential equations , getting error that "free variable must be used in vars"

1 visualización (últimos 30 días)
I am trying to solve the equations :
du/dt = k1*s - k2*v*u dv/dt = k3*s - k4*u*v
For this i followed the code :
syms T t u(t) v(t) u0 v0 Y
Du = diff(u);
Dv = diff(v); k1=1;k2=1;k3=1;k4=1; s=floor(t/4);
ode1 = Du == k1*s-k2*u*v;
ode2 = Dv == k3*s-k4*v;
[ode_vf, ode_subs] = odeToVectorField(ode1,ode2);
ode_fcn = matlabFunction(ode_vf, 'vars',{T,Y});
tspan = linspace(0, 20, 10);
icv = [0; 0]+sqrt(eps);
[t,y] = ode45(ode_fcn, tspan, icv);
figure(1)
plot(t, y)
grid
I get the following error . : see attached image.
>>Error using sym/matlabFunction>checkVarsSubset (line 234) The free variable t must be included in the 'Vars' value.
>>Error in sym/matlabFunction>checkVars (line 222) checkVarsSubset(vexpanded,funvars);
>>Error in sym/matlabFunction (line 154) vars = checkVars(funvars,opts);
Please help me out here !

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by