function transient_analysis_01
% Transient analysis of RLC circuit using ode function
ts=0;     % start time
te=30e-3;  % end time
x0=[0 20];  % initial conditions
[t,x]=ode23(@diffeq,[ts te],x0);
% plot iL(t)
subplot(2,1,1); plot(t,x(:,1));
xlabel('t [s]'); ylabel('iL(t) [A]'); grid on;
% plot uC(t)
subplot(2,1,2); plot(t,x(:,2));
xlabel('t [s]'); ylabel('uC(t) [V]'); grid on;
% differential equations
function dxdt=diffeq(t,x)
R=10; L=31.25e-3; C=50e-6; Is=2;
A=[0        1/L;
   -1/C   -1/(R*C)];
F=[0; Is/C];
dxdt=A*x+F;