Plotting a DT Sinusoid with MATLAB
Using MATLAB, plot the discrete-time sinusoid x[n]=\cos \left(\frac{\pi}{12} n+\frac{\pi}{4}\right).
We represent the desired sinusoid using an anonymous function. Next, we plot this function over the desired range of n. The result, shown in Fig. 3.12, matches the plot of the same signal shown in Fig. 3.11.
>> n = (-30:30); x = @(n) cos(n*pi/12+pi/4);
>> clf; stem(n,x(n),’k’); ylabel(’x[n]’); xlabel(’n’);