Matlab Codes (RC -Transients Circuits)
Plotting RC transient analysis of C = 10 μF, use MATLAB to plot the voltage across the capacitor if R is equal to (a) 1.0 kΩ, (b) 10 kΩ and (c) 0.1 kΩ (d) 0.01 kΩ
Circuit diagram
MatLab Code:-
c = 10e-6;
r1 = 1e3;
pan1 = c*r1;
t = 0:0.002:0.05;
v1 = 10*(1-exp(-t/pan1));
r2 = 10e3;
pan2 = c*r2;
v2 = 10*(1-exp(-t/pan2));
r3 = .1e3;
pan3 = c*r3;
v3 = 10*(1-exp(-t/pan3));
r4 = 0.01e4;
pan4 = c*r4;
v4 = 10*(1-exp(-t/pan4));
plot(t,v1,'+',t,v2,'o', t,v3,'*',t,v4,'-')
axis([0 0.06 0 12])
title('Charging of a capacitor with Four time constants')
xlabel('Time, s')
ylabel('Voltage across capacitor')
text(0.03, 5.0, '+ for R = 1 Kilohms')
text(0.03, 6.0, 'o for R = 10 Kilohms')
text(0.03, 7.0, '* for R = 0.1 Kilohms')
text(0.03, 8.0, '- for R = 0.01 Kilohms')
Output (Graph)