工程测试技术模拟信号采样

摘要

小虎利用MATLAB对余弦函数 y = c o s ( 2 π t ) y=cos(2\pi t) 进行采样,并且将采样后的结果与原结果对比,可以看见,采样能够较符合整个函数的走势。

结果

f=5HZ.
在这里插入图片描述
f=10HZ.(采样点数不变,仍为11个)
在这里插入图片描述
随着采样频率的的升高,采样点会越来越多,精度越高

代码分析

原函数,并画图

t=-1:0.01:1;
x_t=cos(2*pi*t);
plot(t,x_t);

由采样点数和采样频率定义采样函数。

n=-5:5;
fs=5;
xx=cos(2*pi*n/fs);

画图。

stem(n/fs,xx,'r--');
plot(n/fs,xx,'r--');

完整代码

t=-1:0.01:1;
x_t=cos(2*pi*t);
plot(t,x_t);
hold on;
n=-5:5;
fs=5;
xx=cos(2*pi*n/fs);
stem(n/fs,xx,'r--');
plot(n/fs,xx,'r--');
xlabel('t');
ylabel('x(t)');
legend('x(t)','recovery');
发布了82 篇原创文章 · 获赞 70 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/Davidietop/article/details/105222008