% Program1_1
% This program is used to generate a discrete-time sinusoidal signal and draw its plot
clear, % Clear all variables 清除所有变量
close all, % Close all figure windows 关闭所有图形窗口
n = -20: 20; % Specify the interval of time指定时间间隔
w0 = 0.2*pi; % Specify the angular frequency指定角频率
x = sin(w0*n); % Generate the signal 生成的信号
stem(n,x,'k.') % Open a figure window and plot 打开图形窗口并绘制图形
title('Sinusoidal signal x[n]')
xlabel('Time Index n')
clear,close all,
n = -20: 20;
w0 = 0*pi; w1 = 0.1*pi; w2 = 0.2*pi; w3 = 0.8*pi; w4 = 0.9*pi; w5 = 1*pi;
w6 = 1.1*pi; w7 = 1.2*pi;
x0 = cos(w0*n); x1 = cos(w1*n); x2 = cos(w2*n); x3 = cos(w3*n); x4 = cos(w4*n);
x5 = cos(w5*n); x6 = cos(w6*n); x7 = cos(w7*n);
subplot(421), stem(n,x0,'k.') ,ylabel('w0=0')
subplot(422), stem(n,x1,'k.') ,ylabel('w0=0.1*pi')
subplot(423), stem(n,x2,'k.') ,ylabel('w0=0.2*pi')
subplot(424), stem(n,x3,'k.') ,ylabel('w0=0.8*pi')
subplot(425), stem(n,x4,'k.') ,ylabel('w0=0.9*pi')
subplot(426), stem(n,x5,'k.') ,ylabel('w0=1*pi')
subplot(427), stem(n,x6,'k.') ,ylabel('w0=1.1*pi')
subplot(428), stem(n,x7,'k.') ,ylabel('w0=1.2*pi')
% Program1_3
% This program is used to generate a discrete-time sequence
% and draw its plot
clear, % Clear all variables
close all, % Close all figure windows
n = -5:5; % Specify the interval of time, the number of points of n is 11. 指定时间间隔,n的点数为11。
x = [0, 0, 0, 0, 0.1, 1.1, -1.2, 0, 1.3, 0, 0]; % Generate the signal 生成的信号
stem(n,x,'.') % Open a figure window and draw 打开图形窗口并绘制
the plot of x[n]
grid on,
title ('A discrete-time sequence x[n]')
xlabel ('Time index n')
% Program1_4
% This program is used to generate a discrete-time sinusoidal signal
% and draw its plot
clear, % Clear all variables
close all, % Close all figure windows
n = -5:5; % Specify the interval of time
x = [zeros(1,4), 0.1, 1.1, -1.2, 0, 1.3, zeros(1,2)]; % Generate the sequence
stem (n,x,'.') % Open a figure window and draw the plot of x[n]
grid on,
title ('A discrete-time sequence x[n]')
xlabel ('Time index n')
x = [zeros(1,4) x zeros(1, 2)] 来实现 一行四个零,一行两个零