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