摘要
小虎利用MATLAB对余弦函数 进行采样,并且将采样后的结果与原结果对比,可以看见,采样能够较符合整个函数的走势。
结果
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');