PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Time Domain Representation of Continuous and Discrete Signals 29


The step function called Heaviside is indicated as follows:
function stepseq = Heaviside(x)
stepseq = (x>=0);
R.1.98 For example, write a program that returns u(t) and u(t − 2), using the function
Heaviside, over the range − 10 ≤ t ≤ 10.

MATLAB Solution
>> x = -10:0.1:10;
>> stepfun = Heaviside(x);
>> subplot(2, 1, 1);
>> plot(x, stepfun)
>> xlabel(‘t (time)’)
>> title(‘u(t) vs. t’)
>> ylabel(‘Amplitude.’)
>> axis([-10 10 ,0.5 1.5])
>> subplot(2, 1, 2);
>> stepfun = Heaviside(x-2);
>> plot(x, stepfun)
>> axis([-10 10 ,0.5 1.5])
>> title(‘u(t-2) vs. t’)
>> ylabel(‘Amplitude.’);
>> xlabel(‘t (time)’);

See Figure 1.27.

R.1.99 The MATLAB function sign(t) is defi ned as follows:

sign t

t
t
t

()











10


00


 10







The sign(t) function is illustrated in Figure 1.28.

FIGURE 1.27
Plots of u(t) and u(t − 2) of R.1.98.

1.5

Amplitude

Amplitude

1

− 10 − 8 − 6 − 4 − 2 0246810

0.5

1.5

1

0.5
− 10 −^8 −^6 − 4 − 2 024 6 8 10

t (time)

u(t) versus t

u(t−2) versus t

t (time)
Free download pdf