
%EE212 Lab 3 Plot


L=0.47E-3;  % set the inductance equal to 0.47mH
%
a=1E5;   %set the time constant equal to 10usec
%
t=linspace(0,3E-5,1000); % set the time range from 0 to 3 time constants (1000 steps)
%
R=2*L*1E5;
%
% C=1/L*((2*pi*1E6)^2);
%
v=1-exp(-a*t).*cos(2*pi*1E6*t)-(R/(4*pi*1E6*L))*exp(-a*t).*sin(2*pi*1E6*t);
%
%              The .* operator multiplies the two functions together for each value of t.
%
%              If you use the * operator, Matlab tries to multiply the exponention function
%              and the cosine function as a row matrix times a column matrix but they are
%              both row vectors!!
%
w=1+exp(-t*a);
%
plot(t*1E6,v,t*1E6,w,':')  % Two functions are plotted versus t times 1E6 (time scale in microsec)
%
% The following comands make the plot much more meaningful!
%
title('Underdamped RLC Circuit')
grid
xlabel('Time in Microseconds')
ylabel('Capacitor Voltage')
%
text(14,1.8,'f=1E6')     % Add descriptive text to plot
text(14,1.6,'a=1E-5')
%
orient landscape
%print   % Remove the "% sign" before print statement if you want to plot the above functions

