Home / Circuits with Matlab / LC Circuit Analysis using Matlab

LC Circuit Analysis using Matlab

Determine the voltage across the capacitor and the current through the inductor:

Using the following formulae, we can easily obtain the voltage across the capacitor and current through an inductor for time t≥0,

${{i}_{L}}(t)=-\sqrt{\frac{C}{L}}{{V}_{c0}}\sin (\frac{1}{\sqrt{LC}}t)u(t)$

${{v}_{C}}(t)={{V}_{c0}}\cos (\frac{1}{\sqrt{LC}}t)u(t)$

Where

${{V}_{co}}=1V\text{        }\therefore \text{Capacitor Initial Voltage}$

Now, let us write Matlab code to compute voltage and current:

%LC Circuit Analysis
clear all;close all;clc
%%Circuit Parameters
L= 100e-3; %Inductance (100mH)
C=10e-6; % Capacitance (10microFarad) 
omega_o=1/sqrt(L*C); % Angular Frequency
Vco=1; % Capacitor Initial Voltage
Time=0:1e-5:15e-3; % Time Sampling
Vc=Vco.*cos(omega_o.*Time).*heaviside(Time); % Capacitor Voltage
il=-sqrt(C/L)*Vco.*sin(omega_o.*Time).*... % Inductor Current
heaviside(Time);
%%Plotting Capacitor Voltage and Current 
subplot(211)
plot(Time,Vc)
xlabel('Time (s)')
ylabel('Amplitude (V)')
title('V_C')
 
subplot(212)
plot(Time,il)
xlabel('Time (s)')
ylabel('Amplitude (A)')
title('i_L')
%=============================================

Results:

About Ahmad Faizan

Mr. Ahmed Faizan Sheikh, M.Sc. (USA), Research Fellow (USA), a member of IEEE & CIGRE, is a Fulbright Alumnus and earned his Master’s Degree in Electrical and Power Engineering from Kansas State University, USA.

Check Also

Average Power RMS Voltage RMS Current Power Factor Calculation using Matlab

In this tutorial, we will calculate average power, RMS Voltage, RMS Current as well as …

Leave a Reply