How to solve a system of coupled first order differential equations using ode45?
Mostrar comentarios más antiguos
Hello everyone,
I have a system of four coupled first oder differential equation, which needs to be solved. While the equations are long, its pretty straightforward. I have written the following code and getting some error.
function dydt=ccp_ode(t,y)
A_E=.00707;
A_G=0.1650;
e=1.60217663e-19;
n=3.15e16;
l_B=0.1;
epsilon_0=8.85418782e-12;
v_e = 594.0413;
m_e=9.10938e-31;
C_B=2e-9;
m_i=40;
T_e=1.78;
u_B=9.8e3*sqrt(T_e/m_i);
T_ar=300;
p=1;
k_B=1.380649e-23;
n_g=(p/(k_B*T_ar));
I_iP=e*n*u_B*A_E;
I_iG=e*n*u_B*A_G;
L_pl=(l_B*m_e)/(e^2*n*A_E);
K_iz= 2.34e-14*T_e^0.59*exp(-17.44/T_e);
K_ex=2.48e-14*T_e^0.33*exp(-12.78/T_e);
K_el=2.336e-14*T_e^1.609*exp(0.0618*(log(T_e))^2-0.1171*(log(T_e))^3);
Km=K_iz+K_ex+K_el;
v_m=Km*n_g;
v_eff=v_m+(v_e/l_B);
A=2*e*epsilon_0*n*A_E^2;
B=2*e*epsilon_0*n*A_G^2;
C=e*n*v_e*A_E;
D=e*n*v_e*A_G;
f=13.56e6;
omega_1=2*pi*f;
V0=300;
dydt(1)=((-(sqrt(A/y(1)))^-1)*(y(3)+I_iP-(C*exp((-e*y(1))/T_e))));
dydt(2)=((-(sqrt(B/y(2)))^-1)*(-y(3)+I_iG-(D*exp((-e*y(2))/T_e))));
dydt(3)=((L_pl^-1)*((V0*cos(omega_1*t))+y(1)-y(2)+y(4))-(v_eff^y(3)));
dydt(4)=((-1/C_B)*y(3));
end
To call this function I used [t,y]=ode45('ccp_ode', [0 .1], [0 0 2 0]). However I am getting the following error:
Error using odearguments (line 93)
CCP_ODE must return a column vector.

Can anyone please , point me the problem with my code and what is the solution.
Thank You.
1 comentario
MOSLI KARIM
el 25 de Oct. de 2023
function d
[t,y]=ode45(@ccp_ode, [0 .1], [0 0 2 0])
plot(t,y)
function DYDT=ccp_ode(t,y)
A_E=.00707;
A_G=0.1650;
e=1.60217663e-19;
n=3.15e16;
l_B=0.1;
epsilon_0=8.85418782e-12;
v_e = 594.0413;
m_e=9.10938e-31;
C_B=2e-9;
m_i=40;
T_e=1.78;
u_B=9.8e3*sqrt(T_e/m_i);
T_ar=300;
p=1;
k_B=1.380649e-23;
n_g=(p/(k_B*T_ar));
I_iP=e*n*u_B*A_E;
I_iG=e*n*u_B*A_G;
L_pl=(l_B*m_e)/(e^2*n*A_E);
K_iz= 2.34e-14*T_e^0.59*exp(-17.44/T_e);
K_ex=2.48e-14*T_e^0.33*exp(-12.78/T_e);
K_el=2.336e-14*T_e^1.609*exp(0.0618*(log(T_e))^2-0.1171*(log(T_e))^3);
Km=K_iz+K_ex+K_el;
v_m=Km*n_g;
v_eff=v_m+(v_e/l_B);
A=2*e*epsilon_0*n*A_E^2;
B=2*e*epsilon_0*n*A_G^2;
C=e*n*v_e*A_E;
D=e*n*v_e*A_G;
f=13.56e6;
omega_1=2*pi*f;
V0=300;
dydt(1)=((-(sqrt(A/y(1)))^-1)*(y(3)+I_iP-(C*exp((-e*y(1))/T_e))));
dydt(2)=((-(sqrt(B/y(2)))^-1)*(-y(3)+I_iG-(D*exp((-e*y(2))/T_e))));
dydt(3)=((L_pl^-1)*((V0*cos(omega_1*t))+y(1)-y(2)+y(4))-(v_eff^y(3)));
dydt(4)=((-1/C_B)*y(3));
DYDT=dydt'
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!