Laplace Transform for ODE - RC Circuit

5 ビュー (過去 30 日間)
Guilherme Lima
Guilherme Lima 2021 年 3 月 24 日
編集済み: darova 2021 年 3 月 27 日
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)

採用された回答

Paul
Paul 2021 年 3 月 25 日
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 件のコメント
Guilherme Lima
Guilherme Lima 2021 年 3 月 25 日
Hello Paul!
Thanks for your help! It did work! :)
darova
darova 2021 年 3 月 26 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by