MATLAB: Generate a discrete time signal from a given continous time signal

discrete time signal

Lets say I have a continout time signal, x(t) = sin (1000pi*t).
I wanted to generate a sequence of discrete time signal ,x[n] of length 4096, and only print the first 10 values of x[n].
How do I do that , I am super new to matlab.

Best Answer

如果你要对一个连续信号采样从而得到离散的序列,那么首先你需要指定采样率是多少,或者说每个信号周期内你想采多少个点。假定每个周期内采点数量为N,现在你的信号频率为,那么对应的采样率,那么采样间隔为。因此采样代码如下:
N = 10;
f0 = 500;
fs = N*f0;
Ts = 1/fs;
k = 0:4095;
t = k*Ts;
x = sin(2*pi*f0*t);
x(1:10)
以上代码就能得到你想要的结果了。