📄 sincy2.m
字号:
%对sin信号进行抽样得到的结论2
clc
clear
fc=1;%sin信号的频率
a=-4;%信号的起始时间
b=4;%信号的终止时间
ts=1/(32*fc);%为使信号能较平滑的画出,设置的采样时间间隔
fs=1/ts;%由上面的采样时间间隔得到的采样频率
t=a:ts:b;
f=-fs/2+fs/length(t):fs/length(t):fs/2;
%------
f_s=fc*3;%每个sin周期取样3个点时的采样频率
t_s=1/f_s;%由上面的采样频率得到的采样时间间隔
t_c=a:t_s:b;
z1=sin(2*pi*fc*t);%初始相位为0的sin信号
z1_spect=fftshift(abs(fft(z1)));
x1=sin(2*pi*fc*t_c);%用每个sin周期取样3个点时的采样频率,对初始相位为0的sin信号进行抽样后得到的抽样值
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*t+pi/2);%初始相位为pi/2的sin信号
z2_spect=fftshift(abs(fft(z2)));
x2=sin(2*pi*fc*t_c+pi/2);%用每个sin周期取样3个点时的采样频率,对初始相位为pi/2的sin信号进行抽样后得到的抽样值
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*t+pi/6);%初始相位为pi/6的sin信号
z3_spect=fftshift(abs(fft(z3)));
x3=sin(2*pi*fc*t_c+pi/6);%用每个sin周期取样3个点时的采样频率,对初始相位为pi/6的sin信号进行抽样后得到的抽样值
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)原始信号,黑点为初始相位等于0时的抽样点');grid
subplot(2,2,2)
plot(f,z1_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,z2,t_c,x2,'*black');title('(a)原始信号,黑点为初始相位等于pi/2时的抽样点');grid
subplot(2,2,2)
plot(f,z2_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,z3,t_c,x3,'*black');title('(a)原始信号,黑点为初始相位等于pi/6时的抽样点');grid
subplot(2,2,2)
plot(f,z3_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 + -