n = input('Enter n'); t = -n:1:n; subplot(1,2,1); y = sin(t) stem(t,y) xlabel('n'); ylabel('Amplitude'); n = input('Enter n'); t = -n:1:n; subplot(1,2,2); y = cos(t) stem(t,y) xlabel('n'); ylabel('Amplitude');
Output
Enter n5 y = Columns 1 through 9 0.9589 0.7568 -0.1411 -0.9093 -0.8415 0 0.8415 0.9093 0.1411 Columns 10 through 11 -0.7568 -0.9589 Enter n5 y = Columns 1 through 9 0.2837 -0.6536 -0.9900 -0.4161 0.5403 1.0000 0.5403 -0.4161 -0.9900 Columns 10 through 11 -0.6536 0.2837