Experiment no: 1
Experiment name: Analysis of series RC circuit using Matlab.
Objective:
i. To get familiar with MATLAB scripting
ii. Processing array of data programmatically with MATLAB
iii. Plotting data in graph
Introduction:
We can easily analyse series RC circuit using matlab for different values of R and C .
We can also view the voltage across the capacitor for different values of R as well as C very
easily and plot it in a graph for easier realisation . The voltage across the capacitor is given by
the equation
−t
V c =V (1−e τ ) where τ= RC
we can easily plot Vc for different R and C.
circuit diagram:
V0
Clear matlab environment
clear;
clc;
Plot of V_c vs t of series RC circuit When only R changes
Define the variables
C1=10*10^(-6);
R1=logspace(0,7,15);
V=10;
t=0:0.001:2;
Set the figure properties
f1=figure(1);
ax1=axes(f1);
name=['Voltage across capacitor in series RC series circuit'...
'for different values of R'];
set(f1,'Name',name,'NumberTitle',...
'off','Position',[300,60,1200,700]);
hold on;
grid on;
grid minor;
Plotting the figure
l1={};
for i=1:length(R1)
Vc=V*(1-exp(-t/(R1(i)*C1)));
if rem(R1(i),10)==0 && R1(i)>100
text(ax1,t(floor(length(t)*i*.5/length(R1))),...
(Vc(floor(length(t)*i*.5/length(R1)))-0.123),...
['\leftarrow R=' string(R1(i))]);
end
l1{end+1}='R='+string(R1(i));
plot(ax1,t,Vc);
end
Make the figure look nice
leg1=legend(l1);
ylabel('Vc (volts)');
xlabel('Time (Second)');
title(leg1,' Values of R ');
title(ax1,{['Plot of V_c = V ( 1 - \ite^{-t/\tau} )'...
'where \tau = RC'];...
['For different values of R and C=10 \mu F and V=10 V DC'];});
Plot of V_c vs t of series RC circuit When only C changes
Define the variables
C2=logspace(2,5,11)*10^(-6);
R2=300;
V=10;
t=0:0.001:2;
Set the figure properties
f2=figure(2);
ax2=axes(f2);
name2=['Voltage across capacitor in series RC series circuit'...
'for different values of C'];
set(f2,'Name',name2,'NumberTitle',...
'off','Position',[300,50,1200,700]);
hold on;
grid on;
grid minor;
Plotting the figure
l2={};
for i=1:length(C2)
Vc=V*(1-exp(-t/(R2*C2(i))));
if rem(i,2)~=0
text(ax2,t(floor(length(t)*i*.5/length(C2))),...
(Vc(floor(length(t)*i*.5/length(C2)))-0.123),...
['\leftarrow C=' string(C2(i))]);
end
l2{end+1}='C='+string(C2(i))+'\mu F';
plot(ax2,t,Vc);
end
Make the figure look nice
leg2=legend(l2);
ylabel('Vc (volts)');
xlabel('Time (Second)');
title(leg2,' Values of C ');
title(ax2,{['Plot of V_c = V ( 1 - \ite^{-t/\tau} )'...
'where \tau = RC'];...
['For different values of C and R=10 and V=10 V DC'];});
Conclusion:
MATLAB provides many built in functionality for many complex operation. It is very useful for
engineers and scientists. Some complex tasks are easily done using MATLAB . Here many graphs
were plotted to view the response of series RC circuit for different values of R as well different values
of C.