I am generating sine wave in MATLAB with following code

fs=2000e6;%sampling frequency
t=0:1/fs:(1e-6)-1/fs; %1us seconds duration
fc=501e6;%frequency of the cosine wave

The wave it generates is somehing like this enter image description here

My question is: Why do we see amplitude modulation in the wave. Shouldn't amplitudes be 1 at all peaks of the wave? like this wave enter image description here

  • 1
    $\begingroup$ What you're seeing is a plotting artifact (you have more data points that pixels, so Matlab has do discard most data points before plotting). Also, you only have four samples per period, so you can't expect the plot to be super detailed. $\endgroup$
    – MBaz
    Commented Sep 3, 2019 at 13:22
  • 2
    $\begingroup$ I'm voting to close this question as off-topic because this is not a signal processing question. $\endgroup$
    – MBaz
    Commented Sep 3, 2019 at 13:22
  • $\begingroup$ Don't close this question! It is very much a signal processing question and with the confusion it caused related to that, then a very good dsp-puzzle at that! $\endgroup$ Commented Sep 5, 2019 at 0:55

1 Answer 1


To explain what you are seeing (the envelope you see specifically is not a plotting artifact, but a fundamental DSP concept worth explaining) consider if you instead sampled a 500e6 Hz cosine wave at your sampling rate of 2000e6 Hz, which is exactly 4x the sampling rate. This would result in samples 1, 0, -1, 0, 1.... and since Matlab as you plotted would connect the adjacent samples, it would look like the bottom picture. (And if you used plot(x,'o') you would see just three lines).

Now consider your case where you have offset the frequency by 1 Hz, with this the sample location will "roll" along the sine wave, one cycle in the 1 us duration you are using.

This is exactly what you are seeing. The magnitudes 1 and -1 given in the first case are now moving slowly as the sample locations change slowly along the plot due to the slightly higher frequency, and if you use plot(x, 'o') for that case you will more clearly see the sample locations I am speaking of rather than the lines connecting the adjacent samples that are positive and negative (you will see what appears at 4 shapes varying sinusoidally and in quadrature. The envelope is just the artifact of the relatively low sampling rate (you have slightly less than 4 samples per cycle)- not how Matlab plots it.


Not the answer you're looking for? Browse other questions tagged or ask your own question.