Contents
Electric Current in a Series RC Circuit
Solve for the electric current in a series RC circuit. The circuit contains a voltage source V, resistor R and a capacitor C.
At t=0 the switch is closed and from Kirchoff's voltage law (KVL)

Take the derivative of both sides and rearrange

where
is the time constant
clear;close all;clc;
Equations
syms V R C i(t)
current=(diff(i,t)+i/R/C)
current(t) =
diff(i(t), t) + i(t)/(C*R)
Solve
It=dsolve(current,i(0)==V/R)
It =
(V*exp(-t/(C*R)))/R
Plot
V=10;
R=1e3;
C=1e-6;
t=0:R*C/10:5*R*C;
Iout=subs(It,{'V','R','C','t'},{V,R,C,t});
Iout=double(Iout);
figure;plot(t,Iout);
ylabel('Current i');xlabel('Time t');title('Series RC Circuit');
grid on;