RC transient circuit – charging phase

%Yasin khan 
%Lab #4 RC transient circuit - charging phase

clear
clc

E=input('Enter E: '); 
R1=input('Enter R1: '); 
R2=input('Enter R2: '); 
C=input('Enter C: '); 
%calculate for time time constant

tau=R1*C;
tau6 = tau*6;

%create time
time = linspace (0,tau6);

%calculate for vc(t) 
Vc= E*(1-exp(-time/tau));

%calculate for vr(t) 
Vr=E*(exp(-time/tau));

%calculate for ic(t)
Ic=(E/R1)*(exp(-time/tau));

%plot
subplot(3,1,1); plot(time,Vc); title('Vc versus time'); xlabel('Time(sec)'); ylabel('Vc (volts)'); 
subplot(3,1,2); plot(time,Vr); title('Vr versus time'); xlabel('Time(sec)'); ylabel('Vr (volts)'); 
subplot(3,1,3); plot(time,Ic); title('Ic versus time'); xlabel('Time(sec)'); ylabel('Ic (amps)');

Result

RC

Leave a Reply

Your email address will not be published. Required fields are marked *