?? sinccy.m
字號:
%用sinc函數(shù)進(jìn)行低通抽樣定理的證明
clc
clear
a=-5;%信號的起始時間
b=5;%信號的終止時間
fc=1/2;%sinc函數(shù)的最高頻分量值
ts=1/(16*fc);%為使信號能較平滑的畫出,設(shè)置的采樣時間間隔
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;%臨界采樣的時間間隔
t1=a:ts1:b;
x1=sinc(2*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*1;%欠采樣頻率
ts2=1/fs2;%欠采樣的時間間隔
t2=a:ts2:b;
x2=sinc(2*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*4;%過采樣頻率
ts3=1/fs3;%過采樣的時間間隔
t3=a:ts3:b;
x3=sinc(2*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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -