📄 sjbcy.m
字号:
%用三角波函数进行频域低通抽样定理的证明
clc
clear
a=-5;%信号的起始时间
b=5;%信号的终止时间
tc=2;%sinc函数的最高频分量值
fs=1/(32*tc);%为使信号能较平滑的画出,设置的采样时间间隔
ts=1/fs;%由上面的采样时间间隔得到的采样频率
f=a:fs:b;
t=-ts/2+ts/length(f):ts/length(f):ts/2;
y=sinc(tc*f).^2;
y_spect=fftshift(abs(fft(y)));
%------
ts1=tc*2;%临界采样频率
fs1=1/ts1;%临界采样的时间间隔
n1=fs1/fs;
f1=a:fs1:b;%临界采样时刻
x1=sinc(tc*f1).^2;%临界采样得到的采样值
y1=zeros(1,n1*(length(x1)-1)+1);
y1(1:n1:n1*length(x1))=x1;
y1_spect=fftshift(abs(fft(y1)));
z1=convn(y1,sinc(f/fs1),'same');%重建信号
z1_spect=fftshift(abs(fft(z1)));%重建信号的频谱
%-----
ts2=tc*1.5;%欠采样频率
fs2=1/ts2;%欠采样的时间间隔
n2=fs2/fs;
f2=a:fs2:b;%欠采样时刻
x2=sinc(tc*f2).^2;%欠采样得到的采样值
y2=zeros(1,n1*(length(x2)-1)+1);
y2(1:n2:n2*length(x2))=x2;
y2_spect=fftshift(abs(fft(y2)));
z2=convn(sinc(f/fs2),y2,'same');%重建信号
z2_spect=fftshift(abs(fft(z2)));%重建信号的频谱
%----
ts3=tc*3;%过采样频率
fs3=1/ts3;%过采样的时间间隔
n3=fs3/fs;
f3=a:fs3:b;%过采样时刻
x3=sinc(tc*f3).^2;%过采样得到的采样值
y3=zeros(1,n3*(length(x3)-1)+1);
y3(1:n3:n3*length(x3))=x3;
y3_spect=fftshift(abs(fft(y3)));
z3=convn(y3,sinc(f/fs3),'same');%重建信号
z3_spect=fftshift(abs(fft(z3)));%重建信号的频谱
%-------绘图
figure(1)
subplot(3,2,1)
plot(f,y);title('原始信号的频谱');grid
subplot(3,2,2)
plot(t,y_spect);title('原始信号');grid
axis([min(t),max(t),min(y_spect),max(y_spect)])
subplot(3,2,3)
stem(f1,x1);title('临界采样得到的抽样点');grid
subplot(3,2,4)
plot(t,y1_spect);title('抽样点的反傅里叶变换');grid
axis([min(t),max(t),min(y1_spect),max(y1_spect)])
subplot(3,2,5)
plot(f,z1);title('用临界采样得到的抽样点重建的信号');grid
subplot(3,2,6)
plot(t,z1_spect);title('重建信号的反傅里叶变换');grid
axis([min(t),max(t),min(z1_spect),max(z1_spect)])
figure(2)
subplot(3,2,1)
plot(f,y);title('原始信号的频谱');grid
subplot(3,2,2)
plot(t,y_spect);title('原始信号');grid
axis([min(t),max(t),min(y_spect),max(y_spect)])
subplot(3,2,3)
stem(f2,x2);title('欠采样得到的抽样点');grid
subplot(3,2,4)
plot(t,y2_spect);title('抽样点的反傅里叶变换');grid
axis([min(t),max(t),min(y2_spect),max(y2_spect)])
subplot(3,2,5)
plot(f,z2);title('用欠采样得到的抽样点重建的信号');grid
subplot(3,2,6)
plot(t,z2_spect);title('重建信号的反傅里叶变换');grid
axis([min(t),max(t),min(z2_spect),max(z2_spect)])
figure(3)
subplot(3,2,1)
plot(f,y);title('原始信号的频谱');grid
subplot(3,2,2)
plot(t,y_spect);title('原始信号');grid
axis([min(t),max(t),min(y_spect),max(y_spect)])
subplot(3,2,3)
stem(f3,x3);title('过采样得到的抽样点');grid
subplot(3,2,4)
plot(t,y3_spect);title('抽样点的反傅里叶变换');grid
axis([min(t),max(t),min(y3_spect),max(y3_spect)])
subplot(3,2,5)
plot(f,z3);title('用过采样得到的抽样点重建的信号');grid
subplot(3,2,6)
plot(t,z3_spect);title('重建信号的反傅里叶变换');grid
axis([min(t),max(t),min(z3_spect),max(z3_spect)])
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -