1.3 Basic Signal Manipulation and Representation
This section discusses basic tools for mathematically representing and manipulating signals. The motivation is that it is important not only being knowledgeable on manipulating signals using software, but also algebraically, developing expressions and theoretical analysis.
1.3.1 Manipulating the independent variable
Many signal processing tasks require manipulating (for continuous-time signals) or (for discrete-time). A convenient way to introduce this manipulation is by using examples. Define the signal for and 6, and zero otherwise. This signal has only four non-zero amplitude values: and 36,’ at and 6, respectively. The task here is to find new signals based on , namely: , , and .
An interpretation of is that it is a sequence of events that is related to the original (“mother”) sequence but with a time difference. For example, if is interpreted as 6 o’clock and is the heart rate of an animal at that moment, the same measurement is found at but two time units later (8 o’clock). Hence, the notation indicates that and present the same ordinate (in this case, amplitude) values, but these values occur two samples later in when compared to .
One can create a mapping such as Table 1.2, which fills up the first column with values of in the region of interest. Then, it is simple to get columns for , , and . Columns and are filled up based on the auxiliary columns , , and , but they correspond to amplitudes at the value of given in column 1. For example, the second row indicates that and .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example 1.2. Time-reversal of signals. The operation corresponds to flipping the signal over the ordinate axis. In Matlab/Octave it can be implemented with fliplr (left-right) or flipud (up-down) for row and column vectors, respectively. For example, assume that has amplitudes and 5, at time instants and 4, respectively (after discussing the impulse in Section 1.3.4, we will describe this signal as ). One can represent as the row vector x=[3 0 4 0 5] and flip it using y=fliplr(x) in Matlab/Octave. It is important to note that, when representing a signal, one vector can store the amplitude values but not their respective time instants. An additional vector is required to store the time information. Listing 1.2 is a snippet (part of the script) used to generate Figure 1.5. It illustrates the care that must be exercised to properly represent the signals using a computer program. Note that the user must relate the amplitude vector and the “time” vector.
1x=[3 0 4 0 5]; %some signal samples 2y=fliplr(x); %time-reversal 3n1=0:4; %the 'time' axis 4n2=-4:0; %the 'time-reversed' axis 5subplot(211); stem(n1,x); title('x[n]'); 6subplot(212); stem(n2,y); title('y[n]');
Figure 1.5 was produced using three dots to indicate that the signals have infinite duration in spite of being represented by finite-length vectors. Another convention is that, when an amplitude value is not explicitly shown, it is assumed to be zero.
1.3.2 When the independent variable is not an integer
Almost all manipulations of are equally applied to manipulating of discrete-time signals. But a discrete-time signal is undefined if (e. g. in undefined).
For instance, behaves slightly different than given that the discrete-time signal is not defined for non-integer . Therefore, only the amplitude values of for even are present in , while the values for odd are discarded.
Using a similar reasoning, when dealing with a discrete-time signal , it is important to adopt a definition such as:
| (1.2) |
that emphasizes the assumption .
1.3.3 Frequently used manipulations of the independent variable
In signal processing, one is often manipulating the dependent variable (for example, multiplying the signal amplitude by two) and also the independent variable, which is the time abscissa in most cases in this text. These two ways of manipulating a variable are rather different. This section discusses manipulating the independent variable.
One can always use a procedure such as the one illustrated in Table 1.2 to obtain the signal after a manipulation of the independent variable. However, it is worth to memorize the resulting signals in two common situations. The first one is the time shift and the second situation is when simultaneously scaling and shifting the original signal. They are discussed in the next paragraphs.
Example 1.3. Time advance and delay rules of thumb.
It may be convenient to memorize the time advance and delay rules. Assuming , these rules are ( and are assumed, but the same applies to discrete-time and ):
- is a delayed version (right-shifted) of and is an anticipated version (left-shifted) of ;
- is obtained by first considering , which is obtained by advancing the signal by , and then flipping the result with respect to the -axis to obtain
- is also obtained by delaying to create and then flipping this intermediate result over the -axis.
For example, corresponds to finding the temporary result by advancing 3 units of time and then flipping over the -axis. Alternatively, one can think of obtaining by first flipping with respect to the -axis and then delaying by 3 (instead of anticipating it). However, a common mistake is to think that , and start by delaying by 3 and then flipping over the vertical axis. In case of any confusion, the safest option is to map some values of the abscissa such as Table 1.2.
Figure 1.6 provides the example of time-shift, corresponding to a delay of 1. This figure also contrasts manipulating the independent and dependent variables. In the latter case, it is the ordinate (-axis) that is modified, with changing the -axis peak value from 8 to 16. Besides, Figure 1.6 illustrates other two manipulations: contraction and dilation. Note that all three examples of manipulating the independent variable did not modify the ordinate peak value (it is equal to 8). Contraction and dilation are the topic of the next example.
Example 1.4. Time scaling rules of thumb: contraction and dilation.
- Assuming that , corresponds to contracting the time axis by a factor of while corresponds to a dilation by .
For instance, a pulse with support5 from to s leads to a total support duration of seconds, while and have support durations of s and s, respectively. In Figure 1.6, the original signal has a support from to 9 s, with a total support duration of 6 s, while and have supports with total duration of 2 and 12 s, respectively.
Another important manipulation of the independent variable is the simultaneous combination of time-shift and scaling, discussed next.
Example 1.5. Simultaneous scale and shift rules of thumb. The signal , with , is commonly found in signal processing operations. It can also be found as , where . These two representations are related by and . The rules of thumb are:
- for , first expand or contract by a factor of and then shift the intermediate result by ;
- for , first expand or contract the original signal according to the value of , then shift this intermediate result by .
Figure 1.7 provides two examples of simultaneously scaling and shifting a signal .
The first example in Figure 1.7 aims at interpreting . One can always carefully map the signals as done in Table 1.2. But using the rule of thumb is faster. In this case, can be expanded by a factor of and the result shifted to the right (delayed) by . Note that the support of is 6, in the range . The support of is , twice the support of . As expected, the amplitude does not change: for both signals, it has a maximum value of 5.
The second task suggested in Figure 1.7 is to obtain . One possibility is to convert the representation into and proceed as done for . In this case, . To obtain , can be scaled (in this case a contraction) by a factor of and the result shifted to the left by . The support of is .
Instead of using , one can directly operate on , but noting that the time-shift is instead of . In other words, it is an error to try to obtain by first finding and then shifting by . For instance, in Figure 1.7 can be quickly obtained by noting that made the support of to be (half of the support of ), and the time advance shifted to the left.
As a final example that incorporates three manipulations, consider the case of in Figure 1.7. The signal can be obtained by first finding (a new signal with support from to ), then anticipating by (that creates an intermediate signal with support from to ) and then flipping with respect to the y-axis (as in ) to obtain the final result with support from to .
Figure 1.8 provides two examples of manipulating the independent variable of the sinc function, which is defined in Appendix A.12. The function is zero when the abscissa is an integer number , with the exception of . Hence, for , the first zero of is at . The first zero of the signal for can be found using , which leads to , as indicated in Figure 1.8. The contraction and time-shift of is widely used as part of the D/A conversion, as will be discussed in Eq. (3.17).
Example 1.6. Generating graphs of the sinc function. The function sinc in Matlab/Octave can be used to plot a generic sinc with amplitude , support and centered at seconds. The command x = A*sinc((t-gamma)/xi), where t is an array of time instants, provides the amplitude values for the signal
1Ts = 0.001; %sampling interval (in seconds) 2xi = 0.2; %support of the sinc in seconds 3gamma = 0.5; %time shift 4t = -1.6:Ts:1.6; %define discrete-time abscissa with fine resolution 5x = 3*sinc((t-gamma)/xi); %define the signal x(t) 6plot(t,x);
Listing 1.3 provides an example of using sinc to create a graph of a continuous-time signal sinc, which is depicted in Figure 1.9. The continuous-time sinc in Listing 1.3 corresponds to:
and the chosen sampling interval was s. We chose a relatively small value for to obtain a smooth curve representing a continuous-time signal.
1.3.4 Using impulses to represent signals
If you are not familiar with impulses, please first check Appendix A.26.
Recall that the notation indicates that a continuous-time impulse occurs at time . For example, is a delayed impulse occurring at and is an anticipated impulse occurring at . A similar reasoning applies to the discrete-time .
Any discrete-time signal can be conveniently represented by a sum of scaled and shifted impulses. To get the basic idea, consider the following example. An array stores the only non-zero samples of a signal , with the first element corresponding to time , the second one to and so on. How would you write an expression for without using impulses? A wrong guess would be because that corresponds to having a constant DC value of . The impulse helps locating the desired amplitude in time. In this example, given that the first sample occurs at , an expression for using impulses is . Generalizing, any discrete-time signal can be written as
| (1.3) |
In our example, assumes the values for , respectively. As explained, writing does not lead to the proper result because shifted impulses are required to specify the corresponding locations of the amplitudes as they vary over time.
Example 1.7. Revisiting the notation for signals. To complement the discussion in Section 1.2.1, consider interpreting Eq. (1.3) as a single sample at a specific “time” . To make that clear, one can write:
| (1.4) |
and interpret that if and zero otherwise. Hence, the summation eliminates all amplitudes of other than , which is the amplitude of at . In this interpretation, Eq. (1.3) and Eq. (1.4) represent a single sample. Alternatively, one can interpret Eq. (1.3) as the whole sequence. Understanding both interpretations is also useful when dealing with continuous-time impulses as discussed in the next paragraph.
The continuous-time version of Eq. (1.3) is
| (1.5) |
which uses the sifting property of impulses (see Appendix A.26) to show that any continuous-time signal can be represented as a composition of impulses. Besides, similar to to its discrete-time version (Eq. (1.3)), Eq. (1.5) can be interpreted as representing the whole signal or a single sample value at time .
1.3.5 Using step functions to help representing signals
The continuous-time step function is defined as 1 for and 0 for . There is a discontinuity at and the amplitude is conveniently assumed to be . The discrete-time version does not have discontinuities and is defined as 1 for and 0 for . The step function is very useful to indicate signals that are zero for negative values of the independent variable or . Another use is to describe finite-duration signals. When a signal ( or ) has finite support, it is called a finite-duration signal.
It is easy to represent finite-duration signals using a programming language (Python, Java, C, etc.) or an environment such as Matlab or Octave. The step function can be used with the same goal when dealing with expressions. Say for example that the signal has only four non-zero samples at and 6. This signal could be written as .
A side note is that can simplify integrals by limiting the integration interval. For example, when can be obtained by
| (1.6) |
where the role played by is absorbed by changing the inferior limit to 0. After this step, can be eliminated from the integral. In other words, when appears in integrals it can be often taken care of by simply adjusting the integral limits.6
1.3.6 The rect function
The rectangular or rect function corresponds to a normalized pulse with unitary support from to 0.5 and amplitude equals to 1. It can be written as and in some textbooks it is denoted as . The is defined here as a continuous-time function, but there are other definitions, for rectangular discrete-time signals.
As an example of a signal derived from , consider a pulse with amplitude volts and support from 5 to 8 seconds can be denoted as . In this case, as explained in Example 1.5, the value is obtained by observing that the intermediate result has support (or width) from to 1.5, and this range must be delayed by 6.5 to obtain the new support as to 8 s.
Example 1.8. Generating graphs of continuous and discrete-time signals with the rect function. The function rectpuls in Matlab/Octave can be used to plot a generic pulse with amplitude A, support of T and centered at tc seconds. The command x = A*rectpuls(t-tc,T), where t is an array of time instants, provides the amplitude values for the signal
1%% Mimicking a continuous-time signal by using plot 2Ts = 0.001; %sampling interval in seconds 3t = -0.8:Ts:0.8; %discrete-time in seconds 4pulse_width = 0.2; %support of this rect in seconds 5tc = 0.4; %center (in seconds) of this rect 6A = 2.5; %amplitude (in Volts) of this rect 7x = A*rectpuls(t-tc,pulse_width); 8subplot(211), plot(t,x) %plot as a continuos-time signal 9xlabel('t'), ylabel('x(t)') 10%% Making explicit the signal is discrete-time by using stem 11n = -10:10; %discrete-time in seconds 12pulse_width = 5; %support of this rect in samples 13nc = -3; %center (in samples) of this rect 14A = 7; %amplitude (in Volts) of this rect 15x = A*rectpuls(n-nc,pulse_width); 16subplot(212), stem(n,x) %plot as a discrete-time signal 17xlabel('n'), ylabel('x[n]')
Listing 1.4 provides examples of using rectpuls to create graphs of discrete and continuous-time signals, which are depicted in Figure 1.10. The continuous-time rect in Listing 1.4 corresponds to:
One important trick to get a graph that resembles a pulse is to use a small sampling interval, as done in Listing 1.4.
In spite of being defined in continuous-time, it is possible to use it to obtain a discrete-time signal as done, e. g., in Listing 1.4. Defining the sampling interval as second, allows to create a discretized time axis composed only by integers, and then generate
with the key assumption of .
Example 1.9. Generating a signal composed by several rect functions. The goal in this example is to generate the signal
| (1.7) |
using rectpuls in Matlab/Octave. Listing 1.5 provides a solution, and generates Figure 1.11.
1%% Mimicking a continuous-time signal by using plot 2Ts = 0.001; %sampling interval in seconds 3t = -1.6:Ts:1.6; %discrete-time in seconds 4pulse_width = 0.2; %support of this rect in seconds 5x = rectpuls(t,pulse_width) - 3*rectpuls(t-0.2,pulse_width) + ... 6 3*rectpuls(t-0.4,pulse_width); %define the signal 7plot(t,x) %plot as a continuos-time signal 8xlabel('t'), ylabel('x(t)')
Listing 1.5 illustrates a general procedure: one can define a common time axis and compose a sophisticated signal by summing the appropriate parcels.