Laplace Transform for ODE - RC Circuit

12 visualizaciones (últimos 30 días)
Guilherme Lima
Guilherme Lima el 24 de Mzo. de 2021
Editada: darova el 27 de Mzo. de 2021
Hello guys,
I am trying to make a laplace transform from a ODE for a simple RC Circuit.
But When try to use the function subs() in order to replace my laplace transfromed variable >>> laplace(q(t), t, s) for Q(s) I don't see any change at all.
I would like to undestand why and How I can fix this.
Thanks for your helping
%For the capacitor
syms q(t) s
%Charge (C)
%initial condition in the beginning
cond_q = q(0) == 0;
%ODE for capacitor in series with resistor
ode_capacitor = diff(q, t) + P_c*q == Q_c
%Solving ODE
q = dsolve(ode_capacitor, cond_q);
% simplify(q)
% % % Calculate the derivative of 'Charge' - the current(A)
i_c = diff(q)
limit(i_c, t, 0)
limit(i_c, t, inf)
%
% %transformada de laplace
laplace(i_c)
a = laplace(ode_capacitor, t, s)
syms Q
a = subs(a, laplace(q, t, s), Q)

Respuesta aceptada

Paul
Paul el 25 de Mzo. de 2021
I think that last subs command is getting confused because q is defined as the solution of the ode. I'm not sure why that's a problem (or if I'm even correct about that), but you can get around this by using a different variable name as the solution of dsolve:
syms q(t) Q(s) P_c Q_c
cond_q = q(0) == 0;
ode_capacitor = diff(q(t),t) + P_c*q == Q_c;
qsol(t) = dsolve(ode_capacitor,cond_q);
i_c(t) = diff(qsol(t),t);
I_c(s) = laplace(i_c(t));
% Laplace transform of the ode
E(s) = laplace(ode_capacitor);
E(s) = subs(E(s),laplace(q(t),t,s),Q(s));
E(s) = isolate(E(s),Q(s));
Q(s) = rhs(E(s));
Q(s) = subs(Q(s),q(0),0);
% compare Q(s) with laplace(qsol(t))
[Q(s) simplify(laplace(qsol(t)))]
% verify relationship between charge and current
[s*Q(s) I_c(s)]
ans =
[ Q_c/(s*(P_c + s)), Q_c/(s*(P_c + s))]
ans =
[ Q_c/(P_c + s), Q_c/(P_c + s)]
  2 comentarios
Guilherme Lima
Guilherme Lima el 25 de Mzo. de 2021
Hello Paul!
Thanks for your help! It did work! :)
darova
darova el 26 de Mzo. de 2021

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by