Örebro University Support notes Course: Manipulation and control 2010 Singularity functions (in this handout we will follow [1]) Main points covered Instructor: Dimitar Dimitrov Office: T2228 eMail: dimitar.dimitrov@oru.se Tel: 30 14 82 Question hours: ask appointment by email www.aass.oru.se/Research/Learning/drdv.html • Unit-step function • Unit-ramp function • Unit-rectangle function • Unit-triangle function • Signum function • Unit-impulse • Combinations of functions • Amplitude scaling, time shifting and time scaling 1 2 Unit-step function 2 1.5 1.5 step(t) 1 1 0.5 0.5 0 t 0 on −0.5 off on −0.5 −3 −2 −1 0 1 2 3 2 3 −1 1.5 step(t) −1.5 1 −2 −2 0 2 4 6 8 10 Figure 1: Example of a sine signal switched on and off. In red is depicted the actual signal, in dashed blue is a sinusoid. In dashed green is depicted a signal used specify the on and off times for the sinusoid. 0.5 −0.5 −3 Sines, cosines, and exponentials are all continuous and differentiable functions at every point in time. In practice, many important signals are not continuous and differentiable, due to operations like switching a signal on and off for example. Question: how to describe the signal in Fig. 1? t 0 −2 −1 0 1 Figure 2: The unit-step function according to definition (1) (bottom). The top figure depicts a common way of drawing the unit step. Usually step(t) is denoted simply by u(t). We define the (continuous time) unit-step function as 1, step(t) = 12 , 0, t>0 t=0 t<0 (1) Signals of this type can be easily (mathematically) described by multiplying a function that is continuous and differentiable (in the above case sinusoid) by another function that switches from zero to one or from one to zero at some finite time. The unit-step function is useful, because it can mathematically represent a common action in real physical systems - fast switching from one state to another. 3 4 Unit-ramp function Unit-rectangle function 2.5 2 2 1.5 1.5 rect(t) ramp(t) 1 1 0.5 0.5 t 0 t 0 −0.5 −0.5 −2 −1.5 −1 −0.5 0 0.5 1 1.5 2 −2 Figure 3: The unit-ramp function (in blue). In green dashed line is depicted the unit-step function. Another common type of signal is one that is switched on at some time and changes linearly afterwards. We define a unit-ramp function as ramp(t) = = Z t, 0, t>0 t≤0 t step(τ )dτ = t step(t) (2) −∞ The area of the rectangular in Fig. 3 is 0.5 (which is the value of ramp(t) at t = 0.5). 5 −1.5 −1 −0.5 0 0.5 1 1.5 2 Figure 4: The unit-rectangle function. 1, rect(t) = 21 , 0, |t| < 21 |t| = 12 |t| > 12 (3) The unit-rectangle function is very convenient for describing the switching on, then switching off of a signal. When rect(t) multiplies another function the result is zero outside the nonzero range of rect(t) and is equal to the other function inside the nonzero range of rect(t). 6 Unit-triangle function 1.5 f (t) step(t + 0.5) 1 2 0.5 1.5 tri(t) t 0 1 −0.5 0.5 step(t − 0.5) −1 t 0 −2 −1.5 −1 −0.5 0 0.5 1 1.5 2 Figure 5: The unit-rectangle function expressed in terms of step(t + 0.5) − step(t − 0.5). We can think of the application of rect(t) as “opening of a gate”, allowing other functions to go through, and then closing the “gate”. Note that (as i the case of ramp(t)) rect(t) can be expressed in terms of step(t). −0.5 −2 −1.5 −1 −0.5 0 0.5 1 1.5 2 Figure 6: The unit-triangle function. tri(t) = ( 1 − |t|, 0, |t| < 1 |t| ≥ 1 (5) The unit-triangle function can be described as rect(t) = step(t − t0) − step(t − t1), (t0 < t1) (4) where, the notation step(t − t0) means that the unit-step function is shifted with t0 time units. If t0 > 0, then the shift would be a delay. 7 tri(t) = ramp(t + 1) − 2ramp(t) + ramp(t − 1), or tri(t) = (t + 1)step(t + 1) − 2t step(t) + (t − 1)step(t − 1) 8 Signum function 1.5 Unit-impulse sgn(t) 1 δ(t + t3 ) 0.5 δ(t − t1 ) Aδ(t − t2 ) 1 1 1 A t = t3 t=0 t = t1 t = t2 t 0 −0.5 Figure 8: Graphical representation of impulses. The number on the left side denotes the strength of the impulse. −1 −2 δ(t) −1.5 −1 −0.5 0 0.5 1 1.5 An impulse is commonly “illustrated” as a vertical arrow, with a number denoting its strength (see Fig. 8). 2 Figure 7: The signum function. 1, sgn(t) = 0, −1, t>0 t=0 t<0 = 2step(t) − 1 (6) In Fig. 8, the impulse δ(t − t1) is simply δ(t) delayed with t1 time units. The impulse Aδ(t − t2) is simply δ(t) delayed with t2 time units and scaled by a factor of A. We discussed the unit-impulse δ(t) in Handout 7. For nonzero arguments, the value of the signum function has a magnitude of one and a sign that is the same as the sign of its argument. A Matlab implementation of step(t), ramp(t), rect(t), and tri(t) is available on the course web-site in file sfunc.m. In Matlab the signum function is called sign.m. 9 10 Unit-sinc function Combinations of functions We already demonstrated that for describing a given function, we could use sums, differences, products of some available functions (e.g. step(t)). 4 3 2 For example in order to describe the signal depicted in Fig. 1 we used sinc(t) 1 t 0 sin(t)step(t) − sin(t)step(t − 2) + sin(t)step(t − 3) = sin(t) [step(t) − step(t − 2) + step(t − 3)] −1 where, step(t) − step(t − 2) + step(t − 3) is depicted in dashed green line in Fig. 1. Below is given the Matlab code that generates the figure t = -3:0.01:10; y = sin(t); −2 −3 −5 −4 −3 −2 −1 0 1 2 3 4 5 Figure 9: The unit-sinc function. The unit-sinc function is related to the unit-rectangle function (you will use it in your Digital Image Processing course next year). It is the Fourier transform of the unitrectangle function. sinc(t) is called a unit function, because its height and area are one. It is defined by sinc(t) = Note that sinc(0) = 1; sin(πt) πt (7) u1 = sfunc(t,1); u2 = sfunc(t-2,1); u3 = sfunc(t-3,1); hold on; plot(t,y.*(u1-u2+u3),’r’,’LineWidth’,3) plot(t,y,’b--’) plot(t,u1-u2+u3,’g--’) axis([-3 10 -2 2]); grid on; 11 12 Amplitude scaling and shifting Time scaling 3 5 2 −2g(2(t + 3.5)) ) g( t−3 2 g(t) 4 2g(t + 3.5) 1 3 t 0 g(t − 3) g(t) 2 −1 1 t 0 −2 −3 −1 −4 −2 −5 −4 −3 −2 −1 0 1 2 3 4 5 −5 −4 −3 −2 −1 0 1 2 3 4 5 Figure 10: Amplitude scaling and time shifting of a signal. Figure 11: Time scaling. Scaling the amplitude of a signal g(t) by a constraint A can be achieved by Ag(t). Suppose we have an analog tape recording of some music. When we play the tape in the usual way we hear the music as performed but if we increase the speed of the tape movement across the sensing head we hear a speeded-up version of the music. All the frequencies in the original recording are now higher and the time of the performance is reduced. If we slow down the tape the opposite effect occurs. Time shifting of a signal g(t) with t0 time units can be achieved by g(t − t0). For example let t = {0, 1, 2, 3, 4} and f (t) = {5, 6, 7, 7, 8}, • f (t − 1) =? for t = 2, t = 5 • 2f (t − 2) =? for t = 4 13 14 Response of LTI system to different excitations. From Handout 7 we know that if an impulse δ(t) is used to excite a Linear Time-Invariant (LTI) system, the system’s response is called impulse response and we denoted it by h(t). Recall the sifting property h(t) = h(t) ∗ δ(t) = Z h(τ ) 2 2 1.5 1.5 1 1 0.5 0.5 0 0 −0.5 −0.5 −1 −1 0 ∞ −∞ Let us denote the response of an LTI system to a unitstep by hs(t) hs(t) = h(t) ∗ step(t) = = = ∞ Z−∞ ∞ Z−∞ t h(τ )u(t − τ )dτ h(τ )u(−(τ − t))dτ τ 3 4 5 0 1 2 1.5 1 1 0.5 0.5 0 0 −0.5 −0.5 −1 −1 2 τ 3 τ R2 0 2 1 2 4 5 0 1 2 3 4 5 4 5 h(t) τ 3 Figure 12: Visualization of the convolution h(t) ∗ step(t) for t = 2. Note that in the lower-left figure, the product h(t)step(−(τ − t)) is depicted with the dashed green line. (8) −∞ The effect of convolving h(t) with the unit-step function is depicted in Fig. 12. Equation (8) shows that the response of an LTI system to step(t) is the integral of its impulse response. Note that we can we can think of step(t) as the integral of δ(t), hence if an excitation changes to its integral, the response also changes to its integral. 15 2 1.5 0 h(τ )dτ 1 h(t)step(−(τ − t)) h(τ )δ(t − τ )dτ = h(t) Z step(τ − t) We can also turn these relationships around and say that since the first derivative is the “inverse” of integration, if an excitation is changed to its derivative, the response is also changed to its derivative. Rt Recall from equation (2) that ramp(t) = −∞ step(τ )dτ , hence the responseof an LTI system to ramp(t) is given by R t R t −∞ −∞ h(τ )dτ dτ . 16 References [1] M. Roberts, “Fundamentals of Signals & Systems,” Mc Graw Hill, 2008. 17