Sunteți pe pagina 1din 15

Chapter 5

Signals and Systems

Imagine that you are asked to design a system to steer a car straight down the middle of a lane.
Easy, right? Figure out some way to sense the position of the car within its lane. Then, if the car
is right of center, turn the steering wheel to the left. As the car moves so that it is less to the right,
turn the steering wheel less to the left. If it is left of center, turn the steering wheel to the right.
This sort of proportional controller works well for many applications – but not for steering, as can
be seen below.

straight ahead?
steer right

steer right

steer right

straight ahead?

steer left
steer left

Figure 5.1 Simple (but poor) algorithm for steering: steer to the left in proportion to how far the
car is to the right, and vice versa.

Exercise 5.1. Can you explain why the car is oscillating left-to-right and back?

Exercise 5.2. Can you suggest a better algorithm for steering?

It is relatively easy to describe better algorithms in terms that humans would understand: e.g.,
Stop turning back-and-forth! It is not so easy to specify exactly what one might mean by that, in
a way that it could be automated.
In this chapter, we will develop a Signals and Systems framework to facilitate reasoning about the
dynamic behaviors of systems. This framework will enable construction of simple mathematical
Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 144

models that are useful in both analysis and design of a wide range of systems, including the
car-steering system.

5.1 The Signals and Systems Abstraction


To think about dynamic behaviors of systems, we need to think not only about how to describe
the system but also about how to describe the signals that characterize the inputs and outputs of
the system, as illustrated below.

signal signal
system
in out

Figure 5.2 Signals and Systems: the system consumes an input signal and generates an output
signal.

This diagram represents a system with one input and one output. Both the input and output
are signals. A signal is a mathematical function with an independent variable (most often it will
be time for the problems that we will study) and a dependent variable (that depends on the
independent variable). The system is described by the way that it transforms the input signal
into the output signal. In the simplest case, we might imagine that the input signal is the time
sequence of steering-wheel angles (assuming constant accelerator-pedal position) and that the
output signal is the time sequence of distances between the center of the car and the midline of
the lane, and that the output sequence
Representing a system with a single input signal and a single output signal seems too simplistic
for any real application. For example, the car in the steering example (figure 5.1) surely has more
than one possible output signal.

Pause to try 5.1. List at least four possible output signals for the car-steering problem.

Possible output signals include (1) its three-dimensional position (which could be represented by
a 3D vector p̂(t) or by three scalar functions of time), (2) its angular position (again a 3D vector
or three scalar functions of time), (3) the rotational speeds of the wheels (and whether or not they
are sliding), (4) the temperature of the tires (and whether they are about to rupture), and many
other possibilities.
The important point is that the first step in using the signals and systems representation is ab­
straction: we must choose the output(s) that are most relevant to the problem at hand and abstract
away the rest.
To understand the steering of a car, one vital output signal is the lateral position po (t) within the
lane, where po (t) represents the distance (in meters) from the center of the lane. That signal alone
tells us a great deal about how well we are steering. Consider a plot of po (t) that corresponds to
figure 5.1, as follows.
Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 145

po (t)

The oscillations in po (t) as a function of time correspond to the oscillations of the car within its
lane. Thus, this signal clearly represents an important failure mode of our car steering system.
Is po (t) the only important output signal from the car-steering system? The answer to this ques­
tion depends on your goals. Analyzing a system with this single output is likely to give important
insights into some systems (e.g., low-speed robotic steering) but not others (e.g., NASCAR). More
complicated applications may require more complicated models. But all useful models focus on
the most relevant signals and ignore those of lesser significance. 26
Throughout this chapter, we will focus on systems with one input signal and one output signal (as
illustrated figure 5.2). When multiple output signals are important for understanding a problem,
we will find that it is straightforward to generalize the methods and results developed here for
single-input and single-output systems to systems with multiple inputs and outputs.

5.2 Modularity, Primitives, and Composition


The car-steering system can be thought of as the combination of car and steering sub-systems.
The input to the car is the angle of the steering wheel. Let’s call that angle φ(t). The output of the
car is its position in the lane, po (t).

φ(t) car po (t)

The steering controller turns the steering wheel to compensate for differences between our desired
position in the lane, pi (t) (which is zero since we would like to be in the center of the lane) and
our actual position in the lane po (t). Let e(t) = pi (t) − po (t). Thus we can think about the
steering controller as having an input e(t) and output φ(t).

e(t) steering φ(t)


controller

In the composite system, the steering controller determines φ(t) which is the input to the car. The
car generates po (t), which is subtracted from pi (t) to get e(t) (which is the input to the steering
controller). The triangular component is called an inverter: its output is equal to −1 times its
input. More generally, we will use a triangle symbol to indicate that we are multiplying all the
values of the signal by a numerical constant, which is shown inside the triangle.

26
There are always unimportant outputs. Think about the number of moving parts in a car. They are not all important
for steering!
Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 146

e(t) steering φ(t)


pi (t) + car po (t)
controller

−1

The dashed-red box in the previous figure illustrates modularity of the signals and systems ab­
straction. Three single-input, single-output sub-systems (steering controller, car, and inverter)
and an adder (two inputs and 1 output) are combined to generate a new single-input (pi (t)),
single-output (po (t)) system. A principal goal of this chapter is to develop methods of analysis
for the sub-systems that can be combined to analyze the overall system.

5.3 Discrete-Time Signals and Systems


This chapter focuses on signals whose independent variables are discrete (e.g., take on only inte­
ger values). Some such signals are found in nature. For example, the primary structure of DNA
is described by a sequence of base-pairs. However, we are primarily interested in discrete-time
signals, not so much because they are found in nature, but because they are found in computers.
Even though we focus on interactions with the real world, these interactions will primarily oc­
cur at discrete instants of time. For example, the difference between our desired position pi (t)
and our actual position po (t) is an error signal e(t), which is a function of continuous time t. If
the controller only observes this signal at regular sampling intervals T , then its input could be
regarded as a sequence of values x[n] that is indexed by the integer n. The relation between the
sequence x[n] and the continuous signal x(t) is given by

x[n] = x(nT )

which we call the sampling relation. Sampling converts a signal of continuous domain to one of
discrete domain.
While our primary focus will be on time signals, sampling works equally well in other domains.
For example, images are increasingly processed as arrays of pixels accessed by integer-valued
rows and columns, rather than as continuous brightness fields, indexed by real-valued spatial
coordinates.
If the car-steering problem in figure 5.1 were solved in discrete time, we could describe the system
with a diagram that is very similar to the previous continuous-time diagram. However, only
discrete time instants are considered
Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 147

e[n] steering φ[n]


pi [n] + car po [n]
controller

−1

and the output position is now only defined at discrete times, as shown below.
po [n]

5.4 Discrete-time Signals


In this section, we’ll work through the PCAP system for discrete time signals, by introducing
a primitive and three methods of composition, and the ability to abstract by treating composite
signals as if they themselves were primitive.
We will work with a single primitive, called the unit sample, δ. It is defined on all positive and
negative integer indices as follows:

1 if n = 0
δ[n] =
0 otherwise
That is, it has value 1 at index n = 0 and 0 otherwise, as shown below:
δ
1
0 n

Our first operation will be scaling, or multiplication by a scalar. A scalar is any real number. The
result of multiplying any signal x by a scalar c is a signal, such that:

(c · X)[n] = c · X[n]
That is, the resulting signal has a value at every index n that is c times the value of the original
signal at that location. Here are the signals 4δ and −3.3δ.
4δ −3.3 δ
4
0 n

0 n
−3.3
Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 148

The next operation is the delay operation. The result of delaying a signal X is a new signal RX
such that:

RX[n] = X[n − 1]

That is, the resulting signal has the same values as the original signal, but delayed by one step.
You can also think of this, graphically, as shifting the signal one step to the R ight. Here is the
unit sample delayed by 1 and by 3 steps. We can describe the second signal as RRRδ, or, using
shorthand, as R3 δ.

Rδ R3 δ
1 1
0 n 0 n

Finally, we can add two signals together. Addition of signals is component-wise:

(X1 + X2 )[n] = X1 [n] + X2 [n]

That is, the value of the composite signal at step n is the sum of the values of the component sig­
nals. Here are some new signals constructed by summing, scaling, and delaying the unit sample.

3δ + 4Rδ − 2R2 δ
4

δ + R2 δ + R4 δ

1 0 n
0 n

Note that, because each of our operations returns a signal, we can use their results again as ele­
ments in new combinations, showing that our system has true compositionality. In addition, we
can abstract, by naming signals. So, for example, we might define Y = 3δ + 4Rδ − 2R2 δ, and then
make a new signal Z = Y + 0.3RY , which would look like this:

Z = Y + 0.3RY
5

0 n
Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 149

Be sure you understand how the heights of the spikes are determined by the definition of Z.

Exercise 5.3. Draw a picture of samples −1 through 4 of Y − RY .

It is important to remember that, because signals are infinite objects, these combination opera­
tions are abstract mathematical operations. You could never somehow ’make’ a new signal by
calculating its value at every index. It is possible, however, to calculate the value at any particular
index, as it is required.

Advancing
If we allow ourselves one more operation, that of ’advancing’ the signal one step (just
like delaying, but in the other direction, written L for left-shift), then any signal can be
composed from the unit sample, using a (possibly infinite) number of these operations.
We can demonstrate this claim by construction: to define a signal V with value vn at index n, for
any set of integer n, we simply set
X
∞ X

n
v0 δ + vn R δ + v−n Ln δ ,

n=1 n=1

where Rn and Ln are shorthand for applying R and L, respectively, n times.


It is tempting to represent L as 1/R. This representation would simplify the expres­
sions in the previous paragraph. However, in the next chapter, we will represent
systems as operators comprised of adders, scalers, and shifters. If n represents time,
then physical systems are always causal: inputs that arrive after time n0 cannot affect the output
before time n0 . Such systems cannot advance signals: they can be written without L. Further­
more, we shall see that expressions with R in the denominator have an important meanings for
causal systems — and that meaning is very different from L.

Algebraic properties of signals


Adding and scaling satisfy the familiar algebraic properties of addition and multiplication: addi­
tion and scaling are commutative and associative, and scaling distributes over addition:

c(X1 + X2 ) = cX1 + cX2

which can be verified by checking that this relation holds for all n:

(c(X1 +X2 ))[n] = c(X1 [n]+X2 [n]) = cX1 [n]+cX2 [n] = (cX1 )[n]+(cX2 )[n] = (cX1 +cX2 )[n]

Thus the following block diagrams are equivalent.


Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 150

X1 X1 c

+ c c(X1 + X2 ) + cX1 + cX2

X2 X2 c

In addition, R distributes over addition and multiplication, so that:


R(X1 + X2 ) = RX1 + RX2
R(c · X) = c · RX

Exercise 5.4. Verify that R distributes over addition and multiplication by checking that
the appropriate relations hold at some arbitrary step n.

These algebraic relationships mean that we can take any expression involving δ, R, + and · and
convert it into the form

(ao + a1 R1 + a2 R2 + . . . + aN RN )δ

That is, we can express the entire signal as a polynomial in R, applied to the unit sample. In fact,
we have already seen plots of signals expressed in this form.

Sinusoidal signals
We just saw how to construct complicated signals by summing unit sample signals that
are appropriately scaled and shifted. We could similarly start with a family of discretely-
sampled sinusoids as our primitives, where

X[n] = cos(Ωn)

Here are plots of two primitives in this family:

cos(0.2n) cos(1.0n)

Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 151

The second plot may seem confusing, but it’s just a sparsely sampled sinusoid. Note that signals
constructed from even a single sinusoid have non-zero values defined at an infinity of steps; this
is in contrast to signals constructed from a finite sum of scaled and shifted unit samples.

Exercise 5.5. What would be the values of Rcos(0.2n) at steps −3 and 5?

Here are two sinusoids and their sum, made as follows:

S1 [n] = cos(0.2n − π/2)

S2 = R10 S1

S3 = S1 + S2

The blue line is the S1 , the green line is the same signal, delayed by 10, which is S2 , and the red
line is their sum.
1.099

-1.09
0 100

5.5 Systems as Operators


In the next chapter, we’ll develop, in detail, the class of systems known as linear time-invariant
(LTI) systems, which will have a PCAP structure all their own. These systems can themselves be
regarded as operators: a system operates on an input signal. We will find that the structure of a
system determines the types of output signals that the system can produce.
Some systems will produce outputs that persist (and perhaps oscillate forever) even when the
input is as simple as the unit sample. Such output signals can be characterized with the form:
X
Y[n] = λk eσk n cos(Ωk n + φk )) , n > 0.

We’ll refer to −1/σ as the time constant, Ω as the (discrete) frequency, and φ as the phase. Note

that ordinary exponentials fall into this family (with Ω and φ set to 0) and plain sinusoids fall

Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 152

into it (with σ set to 0). Here are two examples of the general class; we will say that the first one
is diverging and the second one, converging.

σ = 0.1, Ω = 0.3 σ = −0.1, Ω = 0.3


We’ll learn to manipulate systems so that they only produce the types of signals that we find to
be desirable. To start, it will be important to examine signals that our systems generate and try to
discover some of these attributes of them.

5.5.1 Analyzing and Conditioning Signals


Given a signal generated by a real-world system (like a robot driving up to, or following, a wall),
what can we do with it? First, we might want to discover its properties, such as its composition
into components and their parameters. Secondly, we might want to perform operations on it to
remove ’noise’ or other aspects of the signal that we think are superficial and not indicative of the
underlying properties of the system.

5.5.2 Root mean squared error


Often, we’ll be interested in how quickly some signal converges to a desired target value; or in
how well an analytical model that we have made of a signal corresponds to its actual values. We
can measure the difference between a finite sample of a signal (say from steps 0 to N − 1) and
a target function f(n), by using a generalization of regular Euclidean distance, called root mean
squared error (RMSE).
If your sample is y0 . . . yN−1 , then the RMSE is
v
u1 X
u N−1
t
(yi − f(i))2
N
i=0

At each sample point, we compute the squared difference between the actual value yi and the
desired value f(i); then we take the average of these squared errors, and finally take the square
root. The units of this error are the units of the original signal.
Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 153

5.5.3 Ten-Ninety
A very rough way to measure how quickly a signal converges to a value is to compute its “ten”
and “ninety” points. This only makes sense for a signal that is converging. If f(y) measures the
distance of a sample value y from a target value, then the “ten” point is the index of the first
sample, yi , for which f(yi ) < (1 − 0.1)f(y0 ). The “ninety” point is the index of the first sample,
yi , for which f(yi ) < (1 − 0.9)f(y0 ). These points are, intuitively, the steps at which the error is
reduced by ten percent, and then by ninety percent.
Here is an example signal, Y[n] = e−0.02n . It reaches 10 percent of the way to 0 at step 6 and 90
percent of the way at step 116:

5.5.4 Estimating period


If a signal is periodic, it may be useful to estimate its period, based on a sequence of samples.
We will assume here that we know some reasonable value that the signal will cross once per
period; it might be a target value that the system is oscillating around, or might be estimated by
determining the mean of the signal. We will call this value the zero, z. The period can then be
estimated as follows:

1. Find the downward crossings of the signal. Those are places where the signal goes from being
above z to below it; that is, indices k where s[k] > z and s[k + 1] 6 z. These crossings mark
whole cycles of the signal.
2. Find the sizes of the gaps between the crossings; these are the lengths of each of the cycles.
3. Return the mean of the gap sizes.

If there are no cycles, then either the signal is aperiodic or the zero was not chosen appropriately.

5.5.5 Exponential fit
If the signal is aperiodic, then we might conjecture that it has an exponential form. Often, it will
be some ’zero’ constant z, plus an exponential; so we’d like to try to characterize our data as well
as possible with the form
Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 154

y[n] = z + bcn = z + ec ln bn

This process is a little bit complicated, but it comes down to considering the values

{ln(y[0] − z), . . . , ln(y[N] − z)} ,

fitting a line y = mx + d to them, to get parameters m and d, and then letting b = em and c = ed

The figures below show exponential fits to the peaks (maximum values) between crossings

(shown as red dots) in both a converging and a diverging signal.

σ = −0.02, ω = 0.1 σ = 0.02, ω = 0.1

5.5.6 Filtering
Filtering is a process used to remove noise or to smooth a signal. Given a function f of some
number k values, we can imagine filtering a signal with f by applying it to successive windows
of k values and using the result as the value of the new signal. More formally, Let Y be the new
signal and X be the old one. Then

Y[i] = f([X[i], . . . , X[i − k + 1]])

There are many different choices of filters (functions f); two common ones are mean and median.
A box or mean filter is defined as:

1 X
k
fmean (vk−1 , . . . , v0 ) = vk ;
k−1
i=0

that is, it is just the mean of the values. Another useful filter is the median filter. It uses the median
function for f.
Here is a signal read in from a file.
Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 155

Here it is with a median and a mean filter of size 3.

Median 3 Mean 3
Here it is with median and mean filters of size 5 and 50. Think about why the mean-filtered
version is smoother than the median-filtered one, and why the tops of the median-50-filtered
signal are flat.
Chapter 5 Signals and Systems 6.01— Fall 2009— November 16, 2009 156

Median 5 Mean 5

Median 50 Mean 50

Exercise 5.6. We can think of the process of applying a polynomial in R as a kind of


filter. Given some polynomial P in R, what filtering function f would have
the same result as applying the transformation described by P?

Exercise 5.7. What polynomial in R corresponds to filtering with a mean filter of size 5?

Exercise 5.8. Is there a polynomial in R that corresponds to filtering with a median filter
of size 3? Why or why not?
MIT OpenCourseWare
http://ocw.mit.edu

6.01 Introduction to Electrical Engineering and Computer Science I

Fall 2009

For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

S-ar putea să vă placă și