matlab采样

所谓模拟信号的数字信号处理方法就是将待处理模拟信号经过采样、量化、编码形成数字信号,并利用数字信号处理方法对采样得到的数字信号进行处理。
下面我们来看一下对模拟信号采样的具体代码。

f=200;               %信号频率为200Hz
t=(0:0.0001:0.1);    %定义信号的时间范围
x=cos(2*pi*f*t);     %生成信号

fs=800;              %采样频率为800Hz
N=80;                %定义采样点数
dt=1/fs;             %采样间隔,采样间隔其实就可以理解为是采样信号的周期,周期=1/频率
T=(0:N-1)*dt;        %定义采样的每个时间点
x1=cos(2*pi*f*T);    %对信号进行采样


subplot(311);
plot(t,x);
ylim([-1 1])
title('原始信号')
subplot(312)
plot(t,x,T,x1,'rp');
ylim([-1 1]);
title('采样过程')

subplot(313)
plot(T,x1);
ylim([-1 1])
xlabel('时间/s')
title('采样后的信号')

 

posted @ 2020-07-06 11:02  wsl96  阅读(1008)  评论(0编辑  收藏  举报