%《通信电子线路》顾宝良 编著
% A.1 信号采样预备知识
% A.1.1
clear
clf;
clc;
f0 = 2e3; %信号频率
t0 = 1/f0; %信号周期
fs = 1e5; %采样频率
ts = 1/fs; %采样周期
t=[-t0/2:ts:t0/2];
N = length(t);
xn = cos(2*pi*f0*t);
subplot(2,1,1);
stem(t*1000,xn,'fill');
grid on;
title('采样时间序列x(n)');
xlabel('T(ms)');
ylabel('Amplitute');
f = (0:N-1)'*fs/N;
mag = abs(fft(xn));
subplot(2,1,2);
plot(f/1000,mag);
grid on;
title('点长 N=51,时间序列x(n)的FFT变换');
xlabel('f(kHz)');
ylabel('Amplitute');