⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dm11201.m

📁 the code of the book come form the book of marlix laboratory with the book of singal
💻 M
字号:
% dm11201
% 信号采样与重构
% k = 1  临界采样  0<k<1  过采样  k>1  欠采样
display('Please input the value of k');
k = input('k = ');
wm = 1;                                   %信号带宽
Ts = k*pi/wm;                             %采样间隔
ws = 2*pi/Ts;                             %采样角频率
wc = ws/2;                                %为简便,滤波器截止频率wc=ws/2
n = -10:10;                               %定义采样点的数量
m = fix(length(n)/2);                     %单边采样周期数,fix函数的功能为取整
nTs = n*Ts;                               %计算每个采样点
dt = 0.05;
t = -m*Ts:dt:m*Ts;
%Sa(t)信号采样
f = sinc(nTs/pi);                        %计算Sa(t)在采样点处的函数值,得到采样信号
%Sa(t)信号重构
fa = f*Ts*wc/pi*sinc((wc/pi)*(ones(length(nTs),1)*t-nTs'*ones(1,length(t)))); 
%Sa(t)包络线
f2=sinc(t/pi);
subplot(311);
stem(nTs,f);                              %绘制采样信号
hold on
plot(t,f2,'r:');                          %绘制包络线
xlabel('t');
title('对sa(t)信号进行采样');
axis([-m*Ts m*Ts -0.5 1.2]);
hold off
subplot(312);
h1=plot(t,fa);                            %绘制重构信号
hold on
for i=-m*Ts:Ts:m*Ts
    ft = sinc(i/pi)*sinc(wc/pi*(t-i));
    h2=plot(t,ft,'m:');                   %绘制重构信号的各个分量
    hold on
    yy = sinc(i/pi);
    yy1 = yy:yy;
    plot(i,yy1,'o');
end
xlabel('t');
title('重构信号');
axis([-m*Ts m*Ts -0.5 1.2]);
legend([h1,h2],'重构信号','分信号');
hold off
subplot(313);
%计算原信号和重构信号之间的误差
error=abs(fa-f2);
plot(t,error);
axis([-m*Ts m*Ts min(error) max(error)+0.1*max(error)]);
xlabel('t');
ylabel('error(t)');  
%End

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -