You are on page 1of 6

RLC Series Circuit

MATLAB code:
w=2*pi*1

res='enter the resistance';


resi=input(res)
indu='enter the inductance';
ind=input(indu)
cond='enter the capacitance';
cap=input(cond)

a=1

t=0:0.01:pi/2

y=a*sin(w*t)
subplot(2,2,1)
plot(y)
xlabel ('time')
ylabel ('Vr')
title ('Vr vs time')

z=(a)*sin(w*t+(pi/2))
subplot(2,2,2)
plot(z)
xlabel ('time')
ylabel ('Vl')
title ('Vl vs time')

r=a*sin(w*t-pi/2)
subplot(2,2,3)
plot(r)
xlabel ('time')
ylabel('Vc')
title ('Vc vs time')

i=(resi^2 + (w*ind - 1./(w*cap))^2)^0.5


subplot(2,2,4)
e=(a./i)*sin(w*t - acos(resi./i))
plot(e)
xlabel ('time')
ylabel ('Current')
title('current vs time')
RLC Parallel Circuit
MATLAB code:
w=2*pi*1

res='enter the resistance';


re=input(res)
indu='enter the inductance';
i=input(indu)
cond='enter the capacitance';
c=input(cond)

a=1
t=0:0.01:pi/2

y=(a./re)*sin(w*t);
subplot(3,1,1)
plot(y)
xlabel ('time')
ylabel ('Current R')
title ('Ir vs time')

z=(a./(w*i))*sin(w*t-pi./2);
subplot(3,1,2)
plot(z)
xlabel ('time')
ylabel ('Current L')
title ('IL vs time')

r=(a*w*c)*sin(w*t+pi./2);
subplot(3,1,3)
plot(r)
xlabel ('time')
ylabel('Current C')
title ('Ic vs time')
RLC Series Resonance
MATLAB code:
R=input('Enter the resistance ')
L=input('Enter the Inductance ')
C=input('Enter the capacitance ')
A=input('Enter amplitude of V')
f=0:0.01:1
w=2*pi*f
xl=w*L
xc=1./w*C
z=sqrt(R.^2+(xl-xc).^2)
I=(A./z)
plot(I)
xlabel('frequency')
ylabel('Current')
title('Resonance I vs f (series)')
RLC Parallel Resonance
MATLAB code:
R=input('Enter the resistance ')
L=input('Enter the Inductance ')
C=input('Enter the capacitance ')
A=input('Enter amplitude of V')
f=0:0.01:1
w=2*pi*f
xl=w*L
xc=1./w*C
Y=sqrt(1./R.^2+(1./xl-1./xc).^2)
I=(A*Y)
plot(I)
xlabel('frequency')
ylabel('Current')
title('Resonance I vs f (parallel)')

You might also like