For the circuit shown, assume that the switch does the opposite of what is shown
ID: 2247935 • Letter: F
Question
For the circuit shown, assume that the switch does the opposite of what is shown. That is, assume the switch has been closed for a long time and opens at time t = 0. Obtain a solution for the current i_L (t) through the inductor and the voltage v_c (t) across the capacitor that is valid for t greaterthanorequalto 0. Use a left to right reference orientation for the inductor current and use - to + and reference for the capacitor with - at the bottom and + at the top. Use MATLAB to plot i_L (t) and v_c (t).Explanation / Answer
R = 1000; %set the value of R and C as 1k and 1uf
C = 1e-6;
t = 0:.0001:.01; %t is a vector from 0 to .01 in steps of .0001
%Use a loop to evaluate the voltage and current equations
for i=1:length(t);
vc(i) = 12*(1-exp(-t(i)/(R*C)));
ic(i) = 12*exp(-t(i)/(R*C));
end
figure(1);clf; %Assign a figure number and clear figure
plot(t, vc); %plot time vs capacitor voltage
title('Capacitor voltage'); %Create a title for this graph
xlabel('Time'); %label the x axis
ylabel('Volts'); %label the y axis
figure(2);clf; %A second figure for the current
plot(t, ic); %plot time vs capacitor current on fig 2
title('Capacitor current'); %add titles and axis labels.
xlabel('Time');
ylabel('milliamps');