Laplace Transform for ODE - RC Circuit

조회 수: 4 (최근 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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by