60 Practical MATLAB® Applications for Engineers
urev = fliplr(un);n1 = -5;
un _ 5 = stepfun(n, n1); fn1=3*(urev .* un _ 5);
subplot(2,1,1)
stem(n,fn1);hold on; plot(n,yzero)
title(‘f1(n) vs. n’);
ylabel(‘Amplitude [f1(n)]’); xlabel(‘Discrete time n’)
un1=stepfun(n,1); fn2=3*(un _ 5 -un1);
axis([-10 10 -1 4])
subplot(2,1,2)
stem(n, fn2);hold on; plot(n,yzero);
title(‘f2(n) vs. n’);
ylabel(‘Amplitude [f1(n)]’); xlabel(‘ Discrete time n ‘);
axis([-10 10 -1 4])
The script fi le sequences is executed and the results are shown in Figure 1.51.Example 1.4Create the script fi le graphs that returns the plots of the following time functions:ft e t ut
1 ()^45 .^14 .tcos(.^83125. ) ()
andf 2 (t) = f 1 (–t)
over the range − 5 ≤ t ≤ 5.FIGURE 1.51
Plots of Example 1.3.f1(n) versus nf2(n) versus n4
321− 1− 10 − 8 − 6 − (^4) − 2 0 2 4 6
Discrete time n
(^810)
Amplitude [f1(n)] 0
Amplitude [f2(n)]
4
3
2
1
0
− 1
− 10 − 8 − 6 − 4 − 2 0246810
Discrete time n