PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

28 Practical MATLAB® Applications for Engineers


R.1.95 A unit step sequence of length N can be generated using the following MATLAB
command:
un = [ones(1, N)]


R.1.96 The shifted (or delayed) unit step sequence u(n − k) can be created by executing the
following MATLAB command:


unk = [zeros(1, k − 1) ones(1, N)]


Observe that the total number of elements of the sequence unk is N + k − 1.


R.1.97 The MATLAB function stepfun(n, no) returns the shifted step (by no units to the
right) sequence shown in Figure 1.26. Recall that the stepfun(n, no) can be used with
either analog or discrete arguments, defi ned as


stepfun n no u n no

nno
nno

(, )( )








1


0


for
for




1.5

1

0.5

−0.5
− 10 −^8 −^6 −^4 −^20246

0

Amplitude

8 10
time index n

δ(n − 3) versus n

FIGURE 1.25
Plot of x(n) = δ(n − 3) of R.1.94.


n 0 n 0 +N

...

stepfun(n, n 0 )

n

FIGURE 1.26
Plot of stepfun(n, no) of R.1.97.

Free download pdf