Laplace Transform for ODE - RC Circuit

5 Ansichten (letzte 30 Tage)
Guilherme Lima
Guilherme Lima am 24 Mär. 2021
Bearbeitet: darova am 27 Mär. 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)

Akzeptierte Antwort

Paul
Paul am 25 Mär. 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 Kommentare
Guilherme Lima
Guilherme Lima am 25 Mär. 2021
Hello Paul!
Thanks for your help! It did work! :)
darova
darova am 26 Mär. 2021

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by