📄 recondemo.m
字号:
%================================================================
% Name: recondemo.m
% Signal sampling and reconstruction
% The original signal is the raised cosin signal.
%================================================================
clear;close all,
wm=2*pi;
a=input('Type in the frequency rate ws/wm=:');
wc=1*wm;
t=-2:0.01:2;
f=(1+cos(pi*t)).*(u(t+1)-u(t-1));
clf;
subplot(221);
plot(t,f);grid on,axis([-2,2,-0.5,2.5]);
title('Original signal');xlabel('t');
ws=a*wm;Ts=2*pi/ws;N=fix(2/Ts);
n=-N:N;
nTs=n*Ts;
fs=(1+cos(pi*nTs)).*(u(nTs+1)-u(nTs-1));
subplot(2,2,2)
stem(n,fs,'.');xlabel('Index n');grid on
title('Sampled version f(nTs)');
fa=zeros(1,length(t));l=length(-N:N);
fa1=fa;
figure(2);
stem(nTs,fs,'.');xlabel('Index n');grid on;hold on
for i=1:l
m=(l-1)/2+1-i;
fa=Ts*(wc)*fs(i)*sinc((wc)*(t+m*Ts)/pi)/pi;
plot(t,fa,'b:');axis([-2,2,-0.5,2.5]);hold on
pause
fa1=fa1+Ts*(wc)*fs(i)*sinc((wc)*(t+m*Ts)/pi)/pi;
end
plot(t,fa1,'r');axis([-2,2,-0.5,2.5]);hold on
figure(1);subplot(223)
plot(t,fa1,'r');axis([-2,2,-0.5,2.5]);
xlabel('t');grid on
title('Reconstructed fa(t)');
error=abs(fa1-f);
subplot(2,2,4)
plot(t,error);grid on
title('Error');xlabel('t')
%===============================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -