Pulse Amplitude Modulation (PAM) MATLAB Tutorial

If you read our last post then you are ready to easily follow this tutorial in which we are going to study the PAM signals generation and their spectra.

Now, the first thing you need to do is to download the code available for this tutorial in our Mathworks profile:http://uk.mathworks.com/matlabcentral/fileexchange/56829-pam-modulation-in-time-and-frequency-domain

If you run it, you will see 6 different figures that may sound familiar to you if you studied the previous post but, to make sure, we are going to explain them here.
Our modulation signal is going to be a continuous cosine. Then, we will obtain 8 samples of that cosine: the sampling frequency, fsim in the code, is divided between 8 so we take one cycle with 8 samples of the signal. Also, we have a continuous time axis for one cycle of the cosine and it’s defined in increments of the sampling period of the continuous cosine. The discrete axis also represents a cycle of the cosine but taking the 8 samples. Therefore, we now have the modulation continuous signal and its 8 samples overlapped:
continuous cycle
Figure 1. Cycle of the cosine and 8 samples of it
Now, we are going to represent the PAM signal, so we add zeros every 2 samples in the samples signal. In addition, we create a pulse of 10 samples duration. By convolving these two signals, we obtain the PAM signal:
PAM signal
Figure 2. PAM signal
Let’s visualize now the continuous and the PAM signals overlapped:
Figure 3. Continuous and PAM signals overlapped
As you can observe, we have represent the signals in a discrete time axis, using 1000 points.
Now, we are going to see the signals in the frequency domain:
Figure 4. PAM signals in the frequency domain
As we can observe, the first spectrum corresponds to the sinusoidal in the time domain: there are 2 deltas, but due to the frequency-axis, we can not differentiate them unless we zoom the image. Also, the sampling is not very accurate and they are not exactly placed in fc=22 hz, but there is a small error because the number of samples taken (1000) is not a power of 2. The sampling frequency is 22000 Hz, so the Nyquist condition is met.
The next image in the figure above, is the spectrum of the sinusoidal cycle of 8 samples: therefore, there are 2 main deltas in fc=22 Hz and the sampling frequency is (22000 Hz )/8 = 2750 Hz, so the Nyquist condition is met as well. However, in this case we can also observe the leakage effect studied in previous posts because the frequency is not a multiple of the sampling frequency (the ratio is 2.75) and the fft algorithm produces this error.
Finally, in the third graph of the previous figure, we have the spectrum of the rectangular pulse, which we have centered in the origin in order to see it better. If you remember the Fourier Transforms pairs, you will know that this is a sinc function.
At this point, we only need to visualize the PAM signal spectrum and the overlapping of it with the continuous signal. Let’s start with the PAM spectrum:
Figure 5. PAM spectrum
Now, the superposition of the previous spectrum and the spectrum of the continuous signal will consist in adding 2 deltas to the previous sinc in fc and -fc:
Figure 6. PAM and continuous signals spectrum


We hope you found useful this tutorial. For more practice with PAM modulation and demodulation (including a channel), you can also download our Simulink model from our Mathworks profilehttp://uk.mathworks.com/matlabcentral/fileexchange/56830-pam-modulator-and-demodulator-with-awgn-channel

Add a Comment

Your email address will not be published. Required fields are marked *