MAE143A Signals & Systems - Homework 2, Winter 2014 —...

7
MAE143A Signals & Systems - Homework 2, Winter 2014 — due by the end of class Thursday January 23, 2014. Question 1 — Zener diode matlab [Chaparro Question 2.2] A zener diode circuit is such that an output corresponding to an input v s (t) = cos(πt) is a clipped sinusoid x(t)= 0.5, v s (t) > 0.5, -0.5, v s (t) < -0.5, v s (t), else. [Figure 2.20 in Chaparro shows the output for a few cycles.] Use matlab to generate the input and output signals and plot them on the same plot for 0 t 4 at time intervals of 0.001. Part (a): Is this system linear? Compare the output obtained from v s (t) with that obtained from 0.3v s (t). Part (b): Is the system time-invariant? Explain. Part (c): Is the system dynamic (i.e. does it have memory)? Explain. Part (d): Is the system stable? Explain. We use matlab to generate the input and output signals and plot them on the same plot for 0 t 4 at time intervals of 0.001. Here is the matlab function for Zener diode function x=Zener_diode(v) % a function to product the output signal from Zener diode % Here the input signal, v, is a scalar and we compute the output signal x. x=zeros(1,1); if v>0.5 x = 0.5; elseif v<-0.5 x = -0.5; else x = v; end return Matlab code for input and output signals. % Question1 clear all; clc; t = [-4:.001:4]’; [n,m] = size(t); x = zeros(n,1); for i = 1:n x(i,1)=Zener_diode(cos(pi * t(i)));

Transcript of MAE143A Signals & Systems - Homework 2, Winter 2014 —...

Page 1: MAE143A Signals & Systems - Homework 2, Winter 2014 — …numbat.ucsd.edu/~bob/signals2014Winter/Signals_&_Systems... · 2014-01-25 · % a function to product the output signal

MAE143A Signals & Systems - Homework 2, Winter 2014— due by the end of class Thursday January 23, 2014.

Question 1 — Zener diode matlab

[Chaparro Question 2.2] A zener diode circuit is such that an output corresponding to an input vs(t) = cos(πt) is a clippedsinusoid

x(t) =

0.5, vs(t) > 0.5,

−0.5, vs(t) < −0.5,vs(t), else.

[Figure 2.20 in Chaparro shows the output for a few cycles.] Use matlab to generate the input and output signals andplot them on the same plot for 0 ≤ t ≤ 4 at time intervals of 0.001.

Part (a): Is this system linear? Compare the output obtained from vs(t) with that obtained from 0.3vs(t).

Part (b): Is the system time-invariant? Explain.

Part (c): Is the system dynamic (i.e. does it have memory)? Explain.

Part (d): Is the system stable? Explain.

We use matlab to generate the input and output signals and plot them on the same plot for 0 ≤ t ≤ 4 at time intervalsof 0.001.Here is the matlab function for Zener diode

function x=Zener_diode(v)% a function to product the output signal from Zener diode% Here the input signal, v, is a scalar and we compute the output signal x.

x=zeros(1,1);if v>0.5

x = 0.5;elseif v<-0.5

x = -0.5;else x = v;endreturn

Matlab code for input and output signals.

% Question1clear all; clc;t = [-4:.001:4]’;[n,m] = size(t);x = zeros(n,1);for i = 1:n

x(i,1)=Zener_diode(cos(pi*t(i)));

Page 2: MAE143A Signals & Systems - Homework 2, Winter 2014 — …numbat.ucsd.edu/~bob/signals2014Winter/Signals_&_Systems... · 2014-01-25 · % a function to product the output signal

−4 −3 −2 −1 0 1 2 3 4

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

Input, Output

Time (sec)

Inpu

t and

Out

put S

igna

ls

InputOutput

Figure 1: Input and Output Signals

endplot(t,cos(pi*t),’r’); % input curvehold on;plot(t,x(:,1),’LineWidth’,2); % output curveaxis([-4 4 -1.2 1.2]);shg;title(’Input, Output’)xlabel(’Time (sec)’);ylabel(’Input and Output Signals’)legend(’Input’,’Output’)grid on

Part (a): No, if the system S is linear, it should satisfy the property S[0.3vs(t)] = 0.3S[vs(t)]. Check this via matlab:

clear all; clc;t = [-4:.001:4]’;[n,m] = size(t);x = zeros(n,1);y = zeros(n,1);for i=1:n

x(i) = Zener_diode(0.3*cos(pi*t(i))); % S(0.3*Vs(t))y(i) = 0.3*Zener_diode(cos(pi*t(i))); % 0.3*S(Vs(t))

endsubplot(2,1,1);plot(t,x); xlabel(’Time (sec)’);ylabel(’S(0.3V_s(t))’)axis([-4 4 -0.4 0.4]); grid on;subplot(2,1,2);plot(t,y); xlabel(’Time (sec)’);ylabel(’0.3*S(V_s(t))’)axis([-4 4 -0.4 0.4]); grid on;shg;

The result is shown in Figure 2. The two signals are clearly different.

Part (b): If the system S is time invariant, it should satisfy S(v(t+ τ)) = x(t+ τ). We know

S(v(t+ τ)) =

0.5, vs(t+ τ) > 0.5

−0.5, vs(t+ τ) < −0.5vs(t+ τ), else

Page 3: MAE143A Signals & Systems - Homework 2, Winter 2014 — …numbat.ucsd.edu/~bob/signals2014Winter/Signals_&_Systems... · 2014-01-25 · % a function to product the output signal

−4 −3 −2 −1 0 1 2 3 4−0.4

−0.2

0

0.2

0.4

Time (sec)

S(0.

3Vs(t)

)

−4 −3 −2 −1 0 1 2 3 4−0.4

−0.2

0

0.2

0.4

Time (sec)

0.3*

S(V s(t)

)

Figure 2: Check linearity for Zener diode. These figures show that the system is not linear

and

x(t+ τ) =

0.5, vs(t+ τ) > 0.5

−0.5, vs(t+ τ) < −0.5vs(t+ τ), else

This shows S(v(t+ τ)) and x(t+ τ) are exactly the same and the system is time-invariant.

Part(c): No. The output is an instantaneous function of the input. It does not depend on previous values of the output orinput signals. To see this, consider some fixed time, T0. Consider any two input signals which differ on the time interval(−∞, T0) but are the same on the interval [T0,∞). Then the outputs will also be the same on the interval [T0,∞). Sothere cannot be any memory in the system and it is non-dynamic.

Part(d)Yes. This system is obviously BIBO stable because a bounded input always produces a bounded output. Indeed,the output is clipped to be bounded in magnitude by 0.5 no matter whether the input is bounded at all.

Question 2 — Analog averaging system

[Chaparro Question 2.3] Consider the analog averager

y(t) =1

T

∫ t+T2

t−T2

x(τ) dτ,

where x(t) is the input signal and y(t) is the output signal. We consider the signals on the time domain t ∈ (−∞,∞).

Part (a): Find the impulse response, h(t), of the averager. Is this system causal?

Part (b): Let x(t) = 1(t), the unit-step function. Find the output, s(t), of the averager. [This is the step response.]

Part (c): Verify that the output signal from Part (b) is the integral of the output signal from Part (a). That is,

s(t) =

∫ t

−∞h(τ) dτ.

Page 4: MAE143A Signals & Systems - Homework 2, Winter 2014 — …numbat.ucsd.edu/~bob/signals2014Winter/Signals_&_Systems... · 2014-01-25 · % a function to product the output signal

00

t

impu

lse

resp

onse

h(t)

00

1

t

step

resp

onse

y(t)

−T/2

−T/2

T/2

T/2

Figure 3: Question2-part(a)(b): Impulse response and Step response

Part(a):Impulse response:

h(t) =1

T

∫ t+T2

t−T2

δ(τ) dτ =

{1T ,−T2 ≤ t ≤

T2

0 , else=

1

T[u(t+

T

2)− u(t− T

2)]

The impulse response is shown in Figure 3. Note that for the impulse response to be non-zero, the time 0 needs to belongto the interval [t− T/2, t+ T/2]. This gives the limits above.

We check the definition of causality: y(t) does not depend on future input values.Check: Since y(t) is related to the behavior of x(t) for t ∈ [t− T

2 , t+T2 ], it depends on future inputs. Not Satisfied! So,

the system is not causal.

Part(b): Step response

y(t) =1

T

∫ t+T2

t−T2

1(τ)dτ =

0, t < −T21T

∫ t+T/20

1 dτ, −T2 ≤ t ≤T2

1T

∫ t+T/2t−T/2 1 dτ, −T2 ≤ t ≤

T2

=

0, t < −T2tT + 1

2 , −T2 ≤ t ≤

T2

1, −T2 ≤ t ≤T2

=1

T(t+

T

2)[u(t+

T

2)− u(t− T

2)] + u(t− T

2)

The step response is shown in Figure 3.

Part(c): If we compare the impulse response and step response in Figure 3, we are pretty sure that the step response isthe integral of the impulse response. Verify:

s(t) =

∫ t

−∞

1

T[u(τ +

T

2)− u(τ − T

2)]dτ

Compute

1

T

∫ t

−∞u(τ +

T

2)dτ =

1

T

{∫ τ=tτ=−T

2u(τ + T

2 )dτ = t+ T2 , t ≥ −T2

0, t < −T2(1)

1

T

∫ t

−∞u(τ − T

2)dτ =

1

T

{∫ τ=tτ=T

2u(τ − T

2 )dτ = t− T2 , t ≥ T

2

0, t < T2

(2)

Page 5: MAE143A Signals & Systems - Homework 2, Winter 2014 — …numbat.ucsd.edu/~bob/signals2014Winter/Signals_&_Systems... · 2014-01-25 · % a function to product the output signal

(1)−(2)

s(t) =

0, t < T

21T (t+

T2 ), −T2 ≤ t <

T2

(t+ T2 )− (t− T

2 ) = 1, t ≥ T2

=1

T(t+

T

2)[u(t+

T

2)− u(t− T

2)] + u(t− T

2)

This shows that the output signal from Part(b) is the integral of the output signal from Part(a).

Question 3 — Differential Equations and Systems

[Roberts Question 4.14] A well-stirred vat has been fed for a long time by two streams of liquid; fresh water at 0.2 cubicmeters per second and concentrated blue dye at 0.1 cubic meters per second. The vat contains 10 cubic meters of thismixture and the mixture is being drained from the vat at a rate of 0.3 cubic meters per second to maintain a constantvolume. The blue dye is suddenly replaced by a red dye at the same flow rate. At what time after the switch in dyes doesthe mixture drawn from the tank have a red-to-blue dye ratio of 99:1?

Let x1 be the volume of blue dye in the tank. Clearly, x1(0) = 10/3. But let us check this later. We have the followingo.d.e. for this volume.

dx1dt

=

{0.1− 0.3× x1

10 , for t < 0,

−0.3x1

10 , for t ≥ 0.

Looking at the steady-state of x1(0−), since the system has been operating for a long time, we have [steady-state = d/dt =0]

0 = 0.1− 0.3x110

or x1 = 10/3.

For t > 0 we have the solution [o.d.e. plus i.c.]

x1(t) = x1(0)e−0.03t =

10

3e−0.03t.

Let x2(t) denote the volume of red dye. Then

x2(t) =10

3− x1(t),

=

{0, for t < 0,103

[1− e−0.03t

], for t ≥ 0.

When the mixture drawn have a red-to-blue dye ratio of 99:1, it satisfies x2(t) = 99× x1(t). Then

10

3

[1− e−0.03t

]= 99× 10

3e−0.03t ⇒ t = 153.5057

Question 4 — Time-varying mass of a car

[Kamen & Heck Question 2.37] Consider (a badly packed) automobile with time-varying mass

M(t) = 1− 0.05× t× [1(t)− 1(t− 10)]− 0.5× 1(t− 10).

Page 6: MAE143A Signals & Systems - Homework 2, Winter 2014 — …numbat.ucsd.edu/~bob/signals2014Winter/Signals_&_Systems... · 2014-01-25 · % a function to product the output signal

The model of velocity of the car is

M(t)dv(t)

dt+ 0.1v(t) = x(t),

where v(t) is the velocity of the car, x(t) is the driving or braking force applied. Compute the velocity v(t) for all t > 0when v(0) = 0 and x(t) = 1(t), the unit-step function. Your expression for v(t) should be completely evaluated (i.e. allintegrals should be evaluated).

Solve it

M(t)dv(t)

dt+ 0.1v(t) = 1(t)⇒ dv(t)

dt+

0.1

M(t)v(t) =

1(t)

M(t)

where

M(t) =

{1− 0.05t, 0 < t < 10

0.5, t ≥ 10

Solve this ODE using the integrating factor method for 1st-order o.d.e.s. The integrating factor is

I(t) = exp[

∫ t

0

(0.1

M(τ))dτ ]

Define

s(τ) =0.1

M(τ)=

{0.1

1−0.05τ , 0 < τ < 10

0.2, τ ≥ 10

Calculate integrating factor remembering that we are only concerned with t > 0.

I(t) = exp[

∫ t

0

s(τ)dτ ],

=

exp[∫ t

00.1

1−0.05τ dτ], 0 < t < 10,

exp[∫ 10

00.1

1−0.05τ dτ +∫ t10

0.2 dτ], t ≥ 10,

=

{exp[−2 ln(1− 0.05t)], 0 < t < 10

exp[−2 ln(0.5) + 0.2(t− 10)], t ≥ 10]

=

{1

(1−0.05t)2 , 0 < t < 10

4e−2e0.2t, t ≥ 10

Note: ∫ t

0

0.1

1− 0.05τdτ = 0.1× 1

−0.05ln(1− 0.05τ)

∣∣∣∣t0

,

= −2[ln(1− 0.05t)− ln 1] = −2 ln(1− 0.05t),∫ t

0

2

20− τdτ = −2 ln(20− τ)|t0 = −2 ln(20− t) + 2 ln(20) = −2 ln

(20− t20

)= −2 ln(1− 0.05t).

Page 7: MAE143A Signals & Systems - Homework 2, Winter 2014 — …numbat.ucsd.edu/~bob/signals2014Winter/Signals_&_Systems... · 2014-01-25 · % a function to product the output signal

So, we have

v(t)× I(t)− v(0) =∫ t

0

1(τ)

M(τ)I(τ)dτ

=

{∫ t0

1(1−0.05τ)3 dτ, 0 < t < 10∫ 10

01

(1−0.05τ)3 dτ + 4e−2∫ t10

e0.2t

0.5 dτ, τ ≥ 10

=

− 1

2 (1− 0.05τ)−2∣∣∣t0, 0 < t < 10

− 12 (1− 0.05τ)−2

∣∣∣t0+ 8e−2 × 1

0.2e0.2t∣∣∣t10, t ≥ 10

=

{− 1

2 (1− 0.05t)−2 + 12 , 0 < t < 10

− 32 − 40 + 40e0.2t−2, t ≥ 10

So

v(t) =

{− 1

2 + 12 (1− 0.05t)2, 0 < t < 10

41.5(1− 0.05t)2 + 40e0.2t−2(1− 0.05t)2, t ≥ 10