?? project_1.m
字號:
%項目一 用MATLAB驗證時域抽樣定理
TN=0.05;TNN=0.005; %前者為抽樣間隔 后者是對原始信號采樣畫圖
Ts1=0.02;Ts2=0.08; %兩種抽樣時間 分別><抽樣間隔TN
n=-200:200;nN=-2000:2000; %抽樣長度
nTs1=n*Ts1;nTs2=n*Ts2;nTN=n*TN;nTNN=n*TNN;
%以小于抽樣間隔抽樣
fs1=cos(8*pi*nTs1)+2*sin(40*pi*nTs1)+cos(24*pi*nTs1); %抽樣信號
ft=cos(8*pi*nTNN)+2*sin(40*pi*nTNN)+cos(24*pi*nTNN); %原始信號
y1=fs1*Ts1*40*sinc(40*(ones(length(nTs1),1)*nTs1-nTs1'*ones(1,length(nTs1)))); %重構信號
error1=abs(fs1-y1);
subplot(2,3,1);
stem(nTs1,fs1,'color','r');
hold on;
plot(nTNN,ft);
xlim([-0.5,0.5]);ylim([-4,4]);
grid on;
subplot(2,3,2);
plot(nTs1,y1);
xlim([-0.5,0.5]);ylim([-4,4]);
grid on;
subplot(2,3,3);
plot(nTs1,error1,'color','g');
xlim([-0.5,0.5]);ylim([-4,4]);
grid on;
%以大于抽樣間隔抽樣
fs2=cos(8*pi*nTs2)+2*sin(40*pi*nTs2)+cos(24*pi*nTs2);
ft=cos(8*pi*nTNN)+2*sin(40*pi*nTNN)+cos(24*pi*nTNN);
y2=fs2*Ts2*40*sinc(40*(ones(length(nTs2),1)*nTs2-nTs2'*ones(1,length(nTs2))));
error2=abs(fs2-y2);
subplot(2,3,4);
stem(nTs2,fs2,'color','r');
hold on;
plot(nTNN,ft);
xlim([-0.5,0.5]);ylim([-4,4]);
grid on;
subplot(2,3,5);
plot(nTs2,y2);
xlim([-0.5,0.5]);ylim([-4,4]);
grid on;
subplot(2,3,6);
plot(nTs2,error2,'color','g');
xlim([-0.5,0.5]);ylim([-4,4]);
grid on;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -