?? sincy4.m
字號(hào):
%對(duì)sin信號(hào)進(jìn)行抽樣得到的結(jié)論4
clc
clear
fc=1;%sin信號(hào)的基準(zhǔn)頻率
a=-4;%信號(hào)的起始時(shí)間
b=4;%信號(hào)的終止時(shí)間
ts=1/(32*fc);%為使信號(hào)能較平滑的畫(huà)出,設(shè)置的采樣時(shí)間間隔
fs=1/ts;%由上面的采樣時(shí)間間隔得到的采樣頻率
t=a:ts:b;
f=-fs/2+fs/length(t):fs/length(t):fs/2;
%------
f_s=fc*3;%過(guò)采樣頻率,即每個(gè)sin周期取樣3個(gè)點(diǎn)
t_s=1/f_s;%由上面的采樣頻率得到的采樣時(shí)間間隔
t_c=a:t_s:b;
z1=sin(2*pi*fc*t);%頻率為'基準(zhǔn)頻率'時(shí)的sin信號(hào)
z1_spect=fftshift(abs(fft(z1)));
x1=sin(2*pi*fc*t_c);%用上面規(guī)定的過(guò)采樣頻率,對(duì)頻率為'基準(zhǔn)頻率'的sin信號(hào)進(jìn)行抽樣后得到的抽樣值
y1=0;
for i=1:length(x1)
y1=y1+x1(i)*sinc((t-t_c(i))/t_s);
end
y1_spect=fftshift(abs(fft(y1)));
%----
z2=sin(2*pi*(fc+f_s)*t);%頻率為'基準(zhǔn)頻率+上面規(guī)定的過(guò)采樣頻率'時(shí)的sin信號(hào)
z2_spect=fftshift(abs(fft(z2)));
x2=sin(2*pi*(fc+f_s)*t_c);%用上面規(guī)定的過(guò)采樣頻率,對(duì)頻率為'基準(zhǔn)頻率+上面規(guī)定的過(guò)采樣頻率'的sin信號(hào)進(jìn)行抽樣后得到的抽樣值
y2=0;
for i=1:length(x2)
y2=y2+x2(i)*sinc((t-t_c(i))/t_s);
end
y2_spect=fftshift(abs(fft(y2)));
%------
z3=sin(2*pi*(fc+2*f_s)*t);%頻率為'基準(zhǔn)頻率+2*上面規(guī)定的過(guò)采樣頻率'時(shí)的sin信號(hào)
z3_spect=fftshift(abs(fft(z3)));
x3=sin(2*pi*(fc+2*f_s)*t_c);%用上面規(guī)定的過(guò)采樣頻率,對(duì)頻率為'基準(zhǔn)頻率+2*上面規(guī)定的過(guò)采樣頻率'的sin信號(hào)進(jìn)行抽樣后得到的抽樣值
y3=0;
for i=1:length(x3)
y3=y3+x3(i)*sinc((t-t_c(i))/t_s);
end
y3_spect=fftshift(abs(fft(y3)));
figure(1)
subplot(2,2,1)
plot(t,z1,t_c,x1,'*black');title('(a)原始信號(hào),黑點(diǎn)為抽樣點(diǎn)');grid
subplot(2,2,2)
plot(f,z1_spect);title('(b)原始信號(hào)的頻譜');grid
subplot(2,2,3)
plot(t,y1);title('(c)用抽樣點(diǎn)重建的信號(hào)');grid
subplot(2,2,4)
plot(f,y1_spect);title('(d)重建信號(hào)的頻譜');grid
figure(2)
subplot(2,2,1)
plot(t,z2,t_c,x2,'*black');title('(a)原始信號(hào),黑點(diǎn)為抽樣點(diǎn)');grid
subplot(2,2,2)
plot(f,z2_spect);title('(b)原始信號(hào)的頻譜');grid
subplot(2,2,3)
plot(t,y2);title('(c)用抽樣點(diǎn)重建的信號(hào)');grid
subplot(2,2,4)
plot(f,y2_spect);title('(d)重建信號(hào)的頻譜');grid
figure(3)
subplot(2,2,1)
plot(t,z3,t_c,x3,'*black');title('(a)原始信號(hào),黑點(diǎn)為抽樣點(diǎn)');grid
subplot(2,2,2)
plot(f,z3_spect);title('(b)原始信號(hào)的頻譜');grid
subplot(2,2,3)
plot(t,y3);title('(c)用抽樣點(diǎn)重建的信號(hào)');grid
subplot(2,2,4)
plot(f,y3_spect);title('(d)重建信號(hào)的頻譜');grid
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -