# E12 Assignment 05

Description:

Problems:
1. Impulse as limiting case of pulse, Laplace Domain

a)  Write an expression for the function, f(t), shown below (a rectangular pulse with area=1).

b)  Write an expression for F(s).

c) As T→0 in the function above, it becomes a unit impulse (i.e., the width is zero and the area is one).  Use your previous result to show that the Laplace Transform of the function is that of a unit impulse. Recall or invoke L'Hôpital as necessary.

d) Repeat a, b, and c for the function shown below (a triangular pulse with area=1).

Solution:

a,b,c)

As T→0, F(s) goes to 0/0, so invoke L'Hôpital.

d)  Slope going up is 4/T².  So function is one slope going up, minus 2 going down at T/2, plus one going up at T.

Again as T→0, F(s) goes to 0/0.

This still results in 0/0, so L'Hôpital again.

2. Partial Fractions, Laplace

Find the Inverse Laplace Transform of the following function using partial fraction expansion.

a)

b)

c)

d) Check your results with Matlab.

...Turn in the Matlab code and output and demonstrate that it agrees with your hand calculations.
Solution:

a)

b)

c)

Since we have a repeated root in the denominator we cross multiply

Equate coefficients of like powers of s, and solve

d)

```>> %Part a
>> [r,p,k]=residue([0 2 5],[1 5 6])
r =
1.0000
1.0000
p =
-3.0000
-2.0000
k =
[]

>> %Part b
>> [r,p,k]=residue([3 0 12],[1 7 6 0])
r =
4
-3
2
p =
-6
-1
0
k =
[]

>> %Part c
>> [r,p,k]=residue([1 0 1],[1 2 1 0])
r =
0
-2
1
p =
-1
-1
0
k =
[]```

3. Complicated Partial Fraction, Laplace (by hand)

Find the Inverse Laplace Transform of the following function by hand using partial fraction expansion (without MATLAB's "residue" command); you may use MATLAB or other tool to solve simultaneous equations involved in Inverse Transform.   Laplace Transform table.

Solution:

Cross multiply

Equate like powers of s

This looks like a pretty full 5x5 set of equations – so either use a computer, or find A and B by cover up method and solve for others

```>> X=[1 0 1 1 0; 6 1 4 4 1; 22 2 14 4 4; 48 10 20 0 4; 40 0 0 0 0];
>> inv(X)*[5 25 76 132 40]'
ans =
1.0000
2.0000
3.0000
1.0000
1.0000```

4. Complicated Partial Fraction, Laplace (Using MATLAB)

a) Find the Inverse Laplace Transform of the following function using partial fraction expansion and Matlab's "residue" command.

b) Compare your Matlab result to the result obtained when doing the partial fraction expansion by hand.

Solution:

a) (Note in the second line I create the denominator polynomial by convolving a polynomial with roots at [0 -2 -2] (this corresponds to the "s(s+2)&sup2" term - note the two roots at s=-2) with the polynomial "s²+2s+10."

```>> N=[5 25 76 132 40];
>> D=conv(poly([0 -2 -2]),[1 2 10]);
>> [r,p,k]=residue(N,D)

r =
0.5000 - 0.0000i
0.5000 + 0.0000i
3.0000
2.0000
1.0000

p =
-1.0000 + 3.0000i
-1.0000 - 3.0000i
-2.0000
-2.0000
0

k =    []

>> abs(r(1))
ans =    0.5000

>> angle(r(1))*180/pi  %Phase angle in degrees (approx zero in this case).
ans = -3.1755e-013```

b)  From class we know that the complex terms (r(1) and r(2)) combine into a single damped cosine with magnitude=2*abs(r(1)), phase=angel(r(1)), decay coefficient=-real(p(1)), omega=image(p(1))

5. MATLAB Element by Element multiplication

The following MATLAB code defines a time vector (row vector) and then a decaying exponential as a row vector (f_r) and a column vector (f_c).

```>> t=linspace(-1,4,51);        % t is a row vector with 51 elements (1x51) from -1 to 4.
>> f_r = exp(-t);              % f_r is a decaying exponential (row vector, 1x51).
>> f_c = exp(transpose(-t));   % f_c is a decaying exponential (column vector 51x1).```

We wish to display .  For each of the following lines of MATLAB code determine which ones will

i) Generate an error?  If there is an error, explain what the error is.
ii) If no error, what is the size of y?
iii) Does it generate an appropriate looking plot?  If the plot is incorrect, explain why.

a)   >> y = heaviside(t)*f_r; plot(t,y)

b)  >> y = heaviside(t).*f_r; plot(t,y);

c)  >> y = f_r.*heaviside(t); plot(t,y);

d)   >> y = heaviside(t)*f_c; plot(t,y);

e)  >> y = heaviside(t).*f_c; plot(t,y);

f) >> y = f_c*heaviside(t); plot(t,y);

g)  >> y = f_c.*heaviside(t'); plot(t,y);

Solution:

a) Error, inner dimensions don't agree (can't multiply two row vectors).

b) All is good, y is 1x51

c)  All is good, y is 1x51

d) No error, but y is 1x1 (a scalar) and plot is wrong (a constant value at 9.8342).

e) Error, dimensions must agree to use element-by-element multiplication (we have one row vector, one column vector).

f)  No error, but y is 51x51 (square matrix).The nth row in y is filled by zeros (for indices equivalent to t<0) , 0.5*y(n) for t=0, and y(n) for t>0). There are 51 columns, and the plot command plots each column as a separate plot so we either get all zeros (for columns with indices equivalent to t<0), a single plot for the column with t=0, and the rest of the plots are for t>0.   There are actually 51 plots, but only three are unique.

g) All is good, y is 51x1.

6. Convolution Ramp with Pulse, Laplace

Derive an expression to verify the result depicted in the image below.  Click here for animation. Animation with h(t) and f(t) switched.  A piecewise description of the output is fine.

a) Find expressions for f(t), h(t), F(s) and H(s)  (Don't use the expression for f(t) that is in the image above, develop your own function that is the sum of ramps and steps).

b) Use the convolution property of the Laplace transform to find G(s) and g(t)=f(t)*h(t)=convolution of f(t) and h(t).

c) The answer, described piecewise, is given by

 Region Convolution t<0 0 0

d) Plot f(t), h(t) and g(t) on the same set of axes with a legend.  Include your printout and your (well commented) code.  It is easiest to use your result from "b" and (element-by-element) multiplication with shifted versions of the heaviside (unit step) function.

Solution:

a) The function f(t) is the sum of a ramp starting at t=0, minus a ramp at t=1 (to get slope to zero), minus a step at t=1 (to get discontinuity)

b)

Collect like exponentials and take inverse transform

c)

d)

```% E12 Homework Problem - Convolution of two signals.
t=linspace(-1,4,1000);  %Define time vector

% Define f(t) with (t>=T) as a step delayed by T seconds.
f=t.*(t>=0)-(t-1).*(t>=1)-(t>=1);

% Define h(t) with a logical function.
h=0.5*((t>=0) & (t<2));

% Define y(t) using heaviside function for step.
y=0.5*(t.^2/2.*heaviside(t)...
-( ((t-1).^2) / 2 + (t-1) ).*heaviside(t-1)...
-( ((t-2).^2) / 2 ).*heaviside(t-2)...
+( ((t-3).^2) / 2 + (t-3) ).*heaviside(t-3));

% Plot all three functions with different colors, then label x-axis, add
plot(t,f,'c-.','Linewidth',2);
hold on;
plot(t,h,'m:','Linewidth',2);
plot(t,y,'g','LineWidth',2);
hold off;
legend({'f(t)','h(t)','y(t)'});
grid on;
xlabel('time');  title('Convolution: y(t)=f(t)*h(t)'); ```

7. Laplace Domain Impulse Response / System Response

The differential equation below describes a physical system with y(t) as output and f(t) as input.

a) Write an expression for H(s), the Laplace Transform of the impulse response of the system (recall that the impulse response is a zero state solution so all initial conditions are zero at t=0-).  In other words, if the input is the unit impulse, f(t)=δ(t), then the output of the system y(t), is equal to the impulse response, h(t)=y(t); find H(s).

b) If the input of the system is f(t)=γ(t), write an expression for Y(s) in terms of H(s). No need to simplify or do partial fractions.

c) If the input of the system is f(t)=sin(ω0t)γ(t), write an expression for Y(s) in terms of H(s).  No need to simplify.

d) Write a general expression for Y(s) in terms of H(s) and F(s).

e) Write a general expression for y(t) in terms of h(t) and f(t).

Solution:

a) Initial conditions are zero, so they need not be considered

b)

c)

d)

e) (Generally easier in Laplace)

a) If is , what is the system differential equation (input=f(t), output=y(t))?

b) If the step response of a system is , what is Hb(s) (as a ratio of polynomials in s)?

c) If the system has , find yZI(t) if .

d) If  , what is H(s) (as a ratio of polynomials in s)?

Solution:

a)

b) Find Y(s), get over a common denominator, multiply by s.

c) We have differential equation (part a), so take Laplace (w/ zero input) and use given I.C.'s

d) Take inverse Laplace of h(t) to get H(s) and then get over common denominator.