📄 sinccy.asv
字号:
%用sinc函数进行低通抽样定理的证明
clc
clear
a=-5;%信号的起始时间
b=5;%信号的终止时间
fc=2;%sinc
ts=1/(16*fc);%采样时间间隔,该值应设置的较小,使信号能较平滑的画出
fs=1/ts;%采样频率
t=a:ts:b;
f=-fs/2+fs/length(t):fs/length(t):fs/2;
y=sinc(fc*t);
y_spect=fftshift(abs(fft(y)));
%------
fs1=fc*1;%临界采样频率
ts1=1/fs1;%临界采样的时间间隔
t1=a:ts1:b;
f1=-fs1/2+fs1/length(t1):fs1/length(t1):fs1/2;
x1=sinc(fc*t1);
y1=0;
for i=1:length(x1)
y1=y1+x1(i)*sinc((t-t1(i))/ts1);
end
y1_spect=fftshift(abs(fft(y1)));
%-----
fs2=fc*0.5;%欠采样频率
ts2=1/fs2;%欠采样的时间间隔
t2=a:ts2:b;
x2=sinc(fc*t2);
y2=0;
for i=1:length(x2)
y2=y2+x2(i)*sinc((t-t2(i))/ts2);
end
y2_spect=fftshift(abs(fft(y2)));
%----
fs3=fc*2;%过采样频率
ts3=1/fs3;%过采样的时间间隔
t3=a:ts3:b;
f2=-fs3/2+fs3/length(t3):fs3/length(t3):fs3/2;
x3=sinc(fc*t3);
y3=0;
for i=1:length(x3)
y3=y3+x3(i)*sinc((t-t3(i))/ts3);
end
y3_spect=fftshift(abs(fft(y3)));
%----
figure(1)
subplot(2,2,1)
plot(t,y,t1,x1,'*black');title('(a)原始信号,黑点为临界采样时的抽样点');grid
subplot(2,2,2)
plot(f,y_spect);title('(b)原始信号的频谱');grid
subplot(2,2,3)
plot(t,y1);title('(c)用临界采样得到的抽样点重建的信号');grid
subplot(2,2,4)
plot(f,y1_spect);title('(d)重建信号的频谱');grid
figure(2)
subplot(2,2,1)
plot(t,y,t2,x2,'*black');title('(a)原始信号,黑点为欠采样时的抽样点');grid
subplot(2,2,2)
plot(f,y_spect);title('(b)原始信号的频谱');grid
subplot(2,2,3)
plot(t,y2);title('(c)用欠采样得到的抽样点重建的信号');grid
subplot(2,2,4)
plot(f,y2_spect);title('(d)重建信号的频谱');grid
figure(3)
subplot(2,2,1)
plot(t,y,t3,x3,'*black');title('(a)原始信号,黑点为过采样时的抽样点');grid
subplot(2,2,2)
plot(f,y_spect);title('(b)原始信号的频谱');grid
subplot(2,2,3)
plot(t,y3);title('(c)用过采样得到的抽样点重建的信号');grid
subplot(2,2,4)
plot(f,y3_spect);title('(d)重建信号的频谱');grid
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -