# E12 Assignment 01

Description:

Problems:
1. Various Forms of the Sifting Integral

In class we showed that

by arguing that the only value of the function f() that matters in the integral is when the argument of the impulse is zero. Using the same idea, evaluate the following integrals.

Solution:

In problems a-d, find the value of "t" that make the argument of the impulse=0. Replace the value of "t" in f() with this value.

For problem e, do the same for the value of "λ".

2. First Order Step Response, No Discontinuity, Time Domain

Consider the circuit below R1=1Ω, R2=2Ω, L=3H

a) If ein(t) is a unit step input find τ, eout(0+), and eout(∞)

b) Find the step response for t≥0.

Solution:

a)  Time constant is L/Req. The Thevenin resistance seen by the inductor is R1 in series with R2, so Req=R1+R2=3Ω, so τ=1.
At t=0+ there is no current through the circuit (because of the inductor) so eout(0+)=0.
As t→∞ the inductor acts as a short circuit, so we have a voltage divider and eout(∞)=ein(∞)*R2/(R1+R2)=2/3V.

b)

3. First Order Impulse Response, No Discontinuity, Time Domain

For the circuit shown, determine the impulse response. R1=1Ω, R2=2Ω, L=3H

Solution:
4. 2nd Order Step Response, Guess and Check

Consider the circuit below C=0.25F, L=1H, R=5Ω

a) Show that it is described by the differential equation

where f(t)=ein(t), and y(t)=eout(t).  A dot above a function denotes differentiation, 2 dots denotes a second derivative...

b) Show that the unit step response (f(t)=γ(t)) is given by

(remember that the unit step response has zero initial conditions at t=0-, i.e., it is a zero state response).

c) The following MATLAB code plots the step response.  Add comments to the code and then turn in the code and the resulting plot.  You will be graded on the quality of your comments.  The file is at e12AsnStepPlot.m.  Note: the MATLAB code "t>=0" will be equal to 0 when t is less than 0 and equal to 1 for t greater than or equal to zero.

Solution:

a) Sum voltages around loop:

b) Characteristic equation is s2+5s+4=(s+4)(s+1), Characteristic values, s=-1, s=-4.   Assume forms of homogeneous and particular solutions:

Put xp(t) into differential equation

Get complete response for t≥0

Get A and B from initial conditions at t=0+. The voltage across the capacitor cannot change instantaneously so

and the current through the inductor cannot change instantaneously, so

So

We multiply by the unit step to make the function valid at all times.

c)

```t=linspace(-1,5,1000);    % Create time vector from -1 to 5 in 1000 steps.
plot(t,t>=0,'b','Linewidth',2); % Plot unit step - the value of t>=0
% is 0 for t<0 and 1 otherwise.  The plot
% will be a thick blue line.
hold on                         % Don't erase first plot

% This "plot" statement plots step response multiplied by (t>=0) to make it
% equal to 0 for negative values of t.  The plot will be a dotted red line.
plot(t,(1+exp(-4*t)/3-4/3*exp(-t)).*(t>=0),'r:');
title('Step Response, E12 Assignment'); % Plot title
xlabel('Time (s)');                     %   x-axis label
ylabel('Voltage (volts)');              %   y-axis label
axis([min(t) max(t) -1 2]);             % Set axis limits
legend('Input','Output');               % Add legend to plot.
hold off                        % Erase plot at next "plot" command.```

5. Second Order, Impulse, Time, No discontinuity

For the previous problem

a) Find an expression for the unit impulse response.

b) Use Matlab to plot it - turn in well commented Matlab code and the resulting plot (you will be graded partly on the quality of your comments).  Use the same time scale as before.

Solution:

a)

but f(t)δ(t)=f(0)δ(t), so

b)

```% Plot the impulse response

t=linspace(-1,5,1000);    % Create time vector from -1 to 5 in 1000 steps.

% This plot statement plots impulse response multiplied by (t>=0) to make it
% equal to 0 for negative values of t.  The plot will be a dotted red line.
plot(t,(exp(-t)-exp(-4*t))*4/3.*(t>=0),'r:');

title('Impulse Response, E12 Assignment'); % Plot title
xlabel('Time (s)');                     %   x-axis label
ylabel('Voltage (volts)');              %   y-axis label
axis([min(t) max(t) -1 2]);             % Set axis limits```

6. First Order Circuit with Discontinuity in Step Response, Time Domain Solution

Consider the circuit below L=1H, R=5Ω

a) Show that it is described by the differential equation

where f(t)=ein(t), and y(t)=eout(t).

b) Show that the unit step response is given by

(remember that the unit step response has zero initial conditions at t=0-, i.e., it is a zero state response).

c) Plot the result for 2 seconds.  Turn in Matlab code (well commented) and the plot.

Solution:

a)  Define current clockwise around circuit

b) We can solve for t≥0

Initial conditions:  Since i(0+)=0, and the voltage across the resistor is zero at t=0+, all voltage must be across inductor

We multiply by the unit step to make the function valid at all times, including t<0.

c)

```t=linspace(-0.1,2,1000);        % Create time vector from -0.1 to 2 in 1000 steps.
plot(t,t>=0,'b','Linewidth',2); % Plot unit step - the value of t>=0
% is 0 for t<0 and 1 otherwise.  The plot
% will be a thick blue line.
hold on                         % Don't erase first plot

% This plot statement plots step response multiplied by (t>=0) to make it
% equal to 0 for negative values of t.  The plot will be a dotted red line.
plot(t,exp(-5*t).*(t>=0),'r:');
title('Step Response, Voltage across inductor, E12 Assignment'); % Plot title
xlabel('Time (s)');                     %   x-axis label
ylabel('Voltage (volts)');              %   y-axis label
axis([min(t) max(t) -1 2]);             % Set axis limits
legend('Input','Output');               % Add legend to plot.
hold off                        % Erase plot at next "plot" command.```

7. First Order, Impulse, Time, Discontinuity

For the previous problem

a) Find an expression for the unit impulse response.

b) Use Matlab to plot the impulse response for the first 2 seconds - turn in well commented Matlab code and plot.  Use the same time scale as before.  (you will be graded partly on the quality of your comments).

You may find this useful: the following code plots an "impulse" with height of 1.5 at a location of -0.5 on the x-axis.  Note: Don't worry that the tip of the arrow extends slightly above 1.5.  This is because the "plot" command centers  the triangular marker used for the arrowhead at the specified location ( (x,y)=(-0.5,1.5) in this example).

`plot([-0.5 -0.5],[0 1.5],'r:');   %plot a red vertical line at x=-0.5 from y=0 to y=1.5plot(-0.5,1.5,'r^','MarkerFaceColor','r');  %put a red triangle at top of line`
Solution:

a)

f(t)δ(t)=f(0)δ(t), so

b)

```% Plot the impulse response

t=linspace(-0.1,2,1000);    % Create time vector from -0.1 to 2 in 1000 steps.

% This plot statement plots impulse response multiplied by (t>=0) to make it
% equal to 0 for negative values of t.  The plot will be a dotted red line.
plot(t,-5*exp(-5*t).*(t>=0),'r:');  %Plot exponential term in response
hold on;

% Now plot impulse by first making a vertical line of lenght one at origin
plot([0 0],[0 1],'r:');
% Put arrowhead on line with a red triangular marker that is filled in.
plot(0,1,'r^','MarkerFaceColor','r');

title('Impulse Response, Voltage across inductor, E12 Assignment'); % Plot title
xlabel('Time (s)');                     %   x-axis label
ylabel('Voltage (volts)');              %   y-axis label
axis([min(t) max(t) -5 2]);             % Set axis limits

hold off```

8. A look at some lab data

Start MATLAB and move the file "HiRes.mat" into that directory (you should see the file in the directory pane of the MATLAB interface).

Enter the following commands:

```load HiRes        % Load data from the HiRes.mat file
e_in=data{1};     % Get input data (voltages)
e_out=data{2};    % Get output
subplot(211);  plot(t,e_in);    % Plot input voltage
xlabel('Time (S)'); ylabel('e_{in}(t) (V)');
title('Input Voltage vs time');
subplot(212);  plot(t,e_out);    % Plot input voltage
xlabel('Time (S)'); ylabel('e_{out}(t) (V)');
title('Output Voltage vs time');```

The voltages plotted above are the input and output voltages (taken from an actual circuit using an oscilloscope) for the circuit below:

Look up what the "diff" command does (>>doc diff at MATLAB prompt). Run the following code.

```e_in_diff = diff(e_in)./diff(t);
e_out_diff = diff(e_out)./diff(t);
tnew = t(1:end-1);

subplot(211);  plot(tnew,e_in_diff);   xlabel('Time (S)');
subplot(212);  plot(tnew,e_out_diff);  xlabel('Time (S)');```

b) Explain the basic shapes of the resulting graphs (a lot of detail is not necessary). Don't worry about the "noisy" nature of the signals.

Note: Numerical differentiation tends to produce results that look "noisy" - as it does in this case. (To think about, but not answer here: why would numerical differentiation be noisy?)

Solution:

Solutions to a and b are in MATLAB code and comments.

```% The "diff" function has, as input, a vector.  The output is another
% vector whose output is the difference between consecutive values in the
% input vector.  For example, the result of "diff([1 3 0])" is "[2 -3]" (2
% is the difference between the first two points, -3 is the difference
% between the next set.
% Note, the output vector is 1 element shorter than the input vector.
e_in_diff = diff(e_in)./diff(t);    % This approximates the derivative of
% the input voltage (difference between
% consecutive voltages divided by the
% difference in time.
% Since input was series of steps,
% this plot is series of impulses.
e_out_diff = diff(e_out)./diff(t);  % Approximate derivative of output.
% Since output was response to steps,
% this plot is series of responses to
% impulses.
tnew = t(1:end-1);                  % Create a new time vector with one
% fewer elements for plotting derivs.

subplot(211);  plot(tnew,e_in_diff);   xlabel('Time (S)');
ylabel('Approx deriv of e_{in}(t)');  title('de_{in}/dt vs t');
subplot(212);  plot(tnew,e_out_diff);  xlabel('Time (S)');
ylabel('Approx deriv of e_{out}(t)');  title('de_{out}/dt vs t');```