Plotting DT Exponentials with MATLAB
Use MATLAB to plot the following discrete-time signals over (0 ≤ n ≤ 8): \text { (a) } x_a[n]=(0.8)^n, \text { (b) } x_b[n]=(-0.8)^n \text {, (c) } x_c[n]=(0.5)^n \text {, and (d) } x_d[n]=(1.1)^n \text {. }
To begin, we use anonymous functions to represent each of the four signals. Next, we plot these functions over the desired range of n. The results, shown in Fig. 3.10, match the earlier Fig. 3.9 plots of the same signals.
>> n = (0:8); x_a = @(n) (0.8).^n; x_b = @(n) (-0.8).^(n);
>> x_c = @(n) (0.5).^n; x_d = @(n) (1.1).^n;
>> subplot(2,2,1); stem(n,x_a(n),’k’); ylabel(’x_a[n]’); xlabel(’n’);
>> subplot(2,2,2); stem(n,x_b(n),’k’); ylabel(’x_b[n]’); xlabel(’n’);
>> subplot(2,2,3); stem(n,x_c(n),’k’); ylabel(’x_c[n]’); xlabel(’n’);
>> subplot(2,2,4); stem(n,x_d(n),’k’); ylabel(’x_d[n]’); xlabel(’n’);