Coupled ODE using ODE15s with multiple outputs
Mostrar comentarios más antiguos
I am looking to solve 2 sets of coupled ODEs (one with dCp1 and the other with dQp1). When I try to use OD15s using,t,Cp1,Qp1] = ode15s(@solver4,[0,15],horzcat(zeros([1,100]))), I get an error message "[Cp1,Qp1] = ode15s(@solver4,[0,15],zeros(1,100))".
Is there a way for ODE15s to solve these 2 sets of coupled ODEs?
function [dCp1 dQp1] = solver4(t,Cp1,Qp1)
n=100;
D=0.008;
u=1;
dCp1=zeros(n,1);
V=1/n;
Qp1(1)=1;
dQp1=zeros(n,1);
kads=1;
kdes=1;
if t<0.1
Cp1(1)=1;
else
Cp1(1)=0;
end
for i=2:n-1
dCp1(i)=D*((Cp1(i-1)-2*Cp1(i)+Cp1(i+1))/(V^2))+u*((Cp1(i-1)-Cp1(i))/V)-(Qp1(i)-Qp1(i-1))/V;
dQp1(i)=kads*Cp1(i)-kdes*Qp1(i);
end
dCp1(n)=(Cp1(n-1)-Cp1(n))/V;
dQp1(n)=kads*Cp1(n)-kdes*Qp1(n);
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Ordinary Differential Equations 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!