% Transient Circuits > RLC > Step Response > Problem 1
% 
% Plot the inductor current and voltage over the range
% t = -0.1 seconds to t=3 seconds

% Create time axis
t_start = -0.1;
t_end = 3.0;
t_inc = 0.01;   % time increment
t = linspace(t_start, t_end, (t_end-t_start)/t_inc);

% Inductor current (expression taken directly from problem solution)
iL = 2 + 14.5 * sin( 4.15*t ) .* exp( -1.67*t );
iL(find(t<0)) = 2;

% Inductor voltage (expression taken directly from problem solution)
vL = 0 + ( 6*cos(4.15*t) - 2.41*sin(4.15*t) ) .* exp( -1.67*t );
vL(find(t<0)) = 0;

% Plot the current and voltage
subplot(2,1,1)
plot(t,iL, 'Color', 'r', 'LineWidth', 2)
grid on
title('Current, iL(t)')
xlabel('t (sec)')
ylabel('iL(t) (A)')

subplot(2,1,2)
plot(t,vL, 'Color', 'g', 'LineWidth', 2)
grid on
title('Voltage, vL(t)')
xlabel('t (sec)')
ylabel('vL(t) (V)')

