92 C H A P T E R 1: Continuous-Time Signals
The signalx 2 (t)has jump discontinuities att=0,t=1, andt=2, and we can think of it as
completely discontinuous so that its continuous component is 0. The derivative is
dx 2 (t)
dt=δ(t)− 2 δ(t− 1 )+δ(t− 2 )The area of each of the deltas coincides with the jump in the discontinuities. nSignal Generation with MATLAB
In the following examples we illustrate how to generate analog signals using MATLAB. This is done by
either approximating continuous-time signals by discrete-time signals or by using the symbolic tool-
box. The functionplotuses an interpolation algorithm that makes the plots of discrete-time signals
look like analog signals.nExample 1.16
Write a script and the necessary functions to generate a signal,y(t)= 3 r(t+ 3 )− 6 r(t+ 1 )+ 3 r(t)− 3 u(t− 3 )Then plot it and verify analytically that the obtained figure is correct.Solution
We wrote functionsrampandustepto generate ramp and unit-step signals for obtaining a numeric
approximation of the signaly(t). The following script shows how these functions are used to gen-
eratey(t). The arguments oframpdetermine the support of the signal, the slope, and the shift (for
advance, a positive number, and for delay, a negative number). Forustepwe need to provide the
support and the shift.%%%%%%%%%%%%%%%%%%%
% Example 1.16
%%%%%%%%%%%%%%%%%%%
clear all; clf
Ts = 0.01; t = -5:Ts:5; % support of signal
% ramp with support [-5, 5], slope of 3 and advanced
% (shifted left) with respect to the origin by 3
y1 = ramp(t,3,3);
y2 = ramp(t,-6,1);
y3 = ramp(t,3,0);
% unit-step function with support [-5,5], delayed by 3
y4 = -3 * ustep(t,-3);
y = y1 + y2 + y3 + y4;
plot(t,y,’k’); axis([-5 5 -1 7]); gridOur functionsrampandustepare as follows.
function y = ramp(t,m,ad)
% ramp generation