Let's say we want to create a sinusoid of the form
![]() |
(1) |
Our first task is to discretize the continuous time variable
. To
do this, we must first determine a sampling rate. Recall this
sampling rate has to be twice the frequency of our signal frequency.
So let's first set
. Therefore, our sampling rate must be at
least 4, but let's make it a little higher, say
.
So this means that our sampling period
is the inverse and the time
between samples is
. Once we set a duration, say
dur=1, we have everything we need to create a sinusoid.
fs = 44100; dur = 1; f0 = 2; nT = 0:1/fs:dur-1/fs; x = cos(2*pi*f0*nT);