📄 sinhscy1.m
字号:
%对sin信号进行抽样得到的结论1
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*2;%临界采样频率,即每个sin周期取样2个点
t_s=1/f_s;%临界采样的时间间隔
n=t_s/ts;
t_c=a:t_s:b;
w1=sin(2*pi*fc*t);%初始相位为0的sin信号
w1_spect=fftshift(abs(fft(w1)));
x1=sin(2*pi*fc*t_c);%对初始相位为0的sin信号,临界采样得到的采样值
y1=zeros(1,n*(length(x1)-1)+1);
y1(1:n:n*length(x1))=x1;
y1_spect=fftshift(abs(fft(y1)));
z1=convn(y1,sinc(t/t_s),'same');%重建信号
z1_spect=fftshift(abs(fft(z1)));%重建信号的频谱
%----
w2=sin(2*pi*fc*t+pi/2);%初始相位为pi/2的sin信号
w2_spect=fftshift(abs(fft(w2)));
x2=sin(2*pi*fc*t_c+pi/2);%对初始相位为pi/2的sin信号,临界采样得到的采样值
y2=zeros(1,n*(length(x2)-1)+1);
y2(1:n:n*length(x2))=x2;
y2_spect=fftshift(abs(fft(y2)));
z2=convn(y2,sinc(t/t_s),'same');%重建信号
z2_spect=fftshift(abs(fft(z2)));%重建信号的频谱
%------
w3=sin(2*pi*fc*t+pi/6);%初始相位为pi/6的sin信号
w3_spect=fftshift(abs(fft(w3)));
x3=sin(2*pi*fc*t_c+pi/6);%对初始相位为pi/6的sin信号,临界采样得到的采样值
y3=zeros(1,n*(length(x3)-1)+1);
y3(1:n:n*length(x3))=x3;
y3_spect=fftshift(abs(fft(y3)));
z3=convn(y3,sinc(t/t_s),'same');%重建信号
z3_spect=fftshift(abs(fft(z3)));%重建信号的频谱
figure(1)
subplot(3,2,1)
plot(t,w1);title('初始相位为0的sin信号');grid
subplot(3,2,2)
plot(f,w1_spect);title('初始相位为0的sin信号的频谱');grid
subplot(3,2,3)
stem(t_c,x1);title('临界采样得到的抽样点');grid
subplot(3,2,4)
plot(f,y1_spect);title('抽样点的频谱');grid
subplot(3,2,5)
plot(t,z1);title('用抽样点重建的信号');grid
subplot(3,2,6)
plot(f,z1_spect);title('重建信号的频谱');grid
figure(2)
subplot(3,2,1)
plot(t,w2);title('初始相位为pi/2的sin信号');grid
subplot(3,2,2)
plot(f,w2_spect);title('初始相位为pi/2的sin信号的频谱');grid
subplot(3,2,3)
stem(t_c,x2);title('临界采样得到的抽样点');grid
subplot(3,2,4)
plot(f,y2_spect);title('抽样点的频谱');grid
subplot(3,2,5)
plot(t,z2);title('用抽样点重建的信号');grid
subplot(3,2,6)
plot(f,z2_spect);title('重建信号的频谱');grid
figure(3)
subplot(3,2,1)
plot(t,w3);title('初始相位为pi/6的sin信号');grid
subplot(3,2,2)
plot(f,w3_spect);title('初始相位为pi/6的sin信号的频谱');grid
subplot(3,2,3)
stem(t_c,x3);title('临界采样得到的抽样点');grid
subplot(3,2,4)
plot(f,y3_spect);title('抽样点的频谱');grid
subplot(3,2,5)
plot(t,z3);title('用抽样点重建的信号');grid
subplot(3,2,6)
plot(f,z3_spect);title('重建信号的频谱');grid
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -