Introduction to Phase Modulation

Phase modulation (PM) is a fundamental analog modulation technique where the phase of a high-frequency carrier signal is varied proportionally to the instantaneous amplitude of the message signal. It is widely used in communication systems, including satellite communications, data transmission, and radar. MATLAB provides a robust environment for simulating and analyzing PM systems, allowing engineers to explore theoretical concepts and validate practical designs without requiring hardware. This expanded tutorial covers the complete implementation of phase modulation in MATLAB, from parameter definitions to demodulation and spectral analysis, with a focus on clear, reproducible code.

Mathematically, a phase-modulated signal s(t) is expressed as:

s(t) = Ac cos(2πfct + kp m(t))

where Ac is the carrier amplitude, fc is the carrier frequency, kp is the phase modulation index (sensitivity), and m(t) is the message signal. The instantaneous phase deviation Δθ = kp·m(t) directly encodes the information. Unlike frequency modulation (FM), PM exhibits a phase deviation that is linear with the message amplitude, making it particularly useful in digital phase shift keying (PSK).

This guide assumes basic familiarity with MATLAB syntax and signal processing concepts. All code snippets are self-contained and can be copied directly into the MATLAB command window or a script file.

Step-by-Step Implementation in MATLAB

1. Defining Parameters and Generating the Message Signal

The first step in any PM simulation is to set the carrier frequency, sampling rate, and time axis, then create a message signal. The choice of sampling frequency must satisfy the Nyquist condition; a practical rule is Fs ≥ 10 × fc to avoid aliasing and ensure smooth waveforms. The message signal can be a sine wave, a square wave, or any arbitrary waveform. For clarity, we start with a simple sinusoidal message.

% ------ Parameter Definition ------
fc = 1000;           % Carrier frequency (Hz)
Fs = 10000;          % Sampling frequency (Hz)
T = 0.01;            % Duration (s)
t = 0 : 1/Fs : T;    % Time vector

% ------ Message Signal (sine wave) ------
Am = 1;              % Message amplitude
fm = 100;            % Message frequency (Hz)
m_t = Am * sin(2 * pi * fm * t);

In practice, the message signal may contain multiple frequency components. To simulate a more realistic scenario, you can replace the sine wave with a sum of sinusoids or a recorded audio file read via audioread. The key parameter here is the message amplitude Am, which directly scales the phase deviation.

2. Generating the Phase-Modulated Carrier

The modulated signal is constructed by computing the instantaneous phase and passing it through a cosine function. The modulation index kp controls the maximum phase deviation. For a sinusoidal message, the maximum phase deviation is kp·Am radians. A value near π/2 produces significant phase swings without causing phase wrapping issues in the unwrapped phase.

% ------ Modulation Index ------
kp = pi/2;           % Phase sensitivity (rad/V)

% ------ Instantaneous phase ------
inst_phase = 2*pi*fc*t + kp * m_t;

% ------ PM Signal ------
s_t = cos(inst_phase);

An alternative, more efficient approach uses the MATLAB built-in pmmod function from the Communications Toolbox:

% Using pmmod (requires Communications Toolbox)
s_t_pmmod = pmmod(m_t, fc, Fs, kp);

The built-in function automatically handles quadrature modulation and is recommended for production simulations. However, for educational purposes, the explicit cosine construction provides insight into the underlying math.

3. Visualizing Time-Domain Waveforms

A proper visualization includes the message signal, the modulated PM signal, and optionally a zoomed view to show the phase shifts. The following code generates a three-panel figure:

figure('Position', [100 100 800 600]);

% Subplot 1: Message signal
subplot(3,1,1);
plot(t, m_t, 'LineWidth', 1.5);
title('Message Signal m(t)');
xlabel('Time (s)'); ylabel('Amplitude'); grid on;

% Subplot 2: PM signal
subplot(3,1,2);
plot(t, s_t, 'LineWidth', 1.2);
title(['PM Signal (k_p = ', num2str(kp), ' rad/V)']);
xlabel('Time (s)'); ylabel('Amplitude'); grid on;

% Subplot 3: Zoomed view (first few cycles)
subplot(3,1,3);
plot(t, s_t, 'LineWidth', 1.2);
hold on;
plot(t, cos(2*pi*fc*t), '--r', 'LineWidth', 1.2); % unmodulated carrier
xlim([0 0.003]); % Show 3 ms
title('PM Signal vs Unmodulated Carrier (Zoomed)');
xlabel('Time (s)'); ylabel('Amplitude'); grid on;
legend('PM Signal', 'Carrier', 'Location', 'northeast');

Observe how the zero-crossings of the PM signal are advanced or delayed relative to the unmodulated carrier—this is the phase deviation caused by the message. As the message amplitude increases, the phase shift becomes more pronounced.

4. Spectral Analysis of the PM Signal

Phase modulation spreads the carrier power across sidebands. The bandwidth depends on both the message frequency and the modulation index. MATLAB’s pwelch function provides a Welch periodogram for power spectral density (PSD) estimation. For a sinusoidal message, the spectrum consists of discrete lines at fc ± n·fm with amplitudes given by Bessel functions.

% ------ Power Spectral Density ------
figure;
pwelch(s_t, hamming(256), [], [], Fs, 'centered', 'power');
title('Power Spectral Density of Phase-Modulated Signal');
xlabel('Frequency (Hz)'); ylabel('Power/Frequency (dB/Hz)');
grid on;

The spectrum clearly shows the carrier at 1 kHz and symmetric sidebands. Increasing the modulation index kp adds more sidebands and broadens the bandwidth. Compare this with a narrowband PM (kp < 0.5 rad) that only has significant power in the first sideband pair, versus wideband PM that excites many sidebands.

Phase Demodulation Techniques

Recovering the message signal from a PM waveform is essential for practical communication receivers. Several demodulation methods exist; we present two common approaches: the Hilbert-transform-based differentiator and the PLL (phase-locked loop).

Demodulation via Hilbert Transform and Phase Unwrapping

This method computes the analytic signal using the Hilbert transform, extracts the instantaneous phase, unwraps it to remove 2π discontinuities, differentiates to obtain the frequency deviation (since phase derivative is proportional to message), and scales by kp. It works well for high SNR environments.

% ------ Demodulation via Phase Difference ------
analytic_sig = hilbert(s_t);          % Analytic signal
inst_phase_unwrapped = unwrap(angle(analytic_sig)); % Unwrap phase
% Differentiate to get frequency deviation
phase_diff = diff(inst_phase_unwrapped) * Fs; % rad/s
demod_m = phase_diff / kp;            % Remove modulation index

% Remove DC offset (carrier frequency residue)
demod_m = demod_m - mean(demod_m);    % Normalize

% Plot
figure;
plot(t(1:end-1), demod_m, 'LineWidth', 1.5);
hold on;
plot(t, m_t, '--k', 'LineWidth', 1);
title('Demodulated Message Signal (Hilbert Method)');
xlabel('Time (s)'); ylabel('Amplitude');
legend('Demodulated', 'Original Message', 'Location', 'southeast');
grid on;

The differentiator introduces high‑frequency noise; a low‑pass filter (e.g., lowpass(demod_m, fm*2, Fs)) can be added to smooth the output. Note that the length of demod_m is one sample shorter than t due to the diff operation.

Demodulation Using a Phase-Locked Loop (PLL)

A PLL synchronizes a local oscillator to the PM signal and extracts the phase error. MATLAB’s Communications Toolbox provides pll objects or you can implement a simple second‑order PLL. A basic discrete-time PLL structure consists of a phase detector (multiplier), a loop filter, and a voltage-controlled oscillator (VCO). The following example uses a simplified approach:

% Simple PLL demodulation (first-order)
phi_hat = 0;                 % Initial phase estimate
prev_phi_hat = 0;
demod_pll = zeros(size(t));
Kp_pll = 0.1;                % Loop gain (tune for stability)
for n = 1:length(t)
    % Phase detector: multiply input with local carrier
    error = s_t(n) * sin(2*pi*fc*t(n) + phi_hat);
    % Loop filter (first-order)
    phi_hat = phi_hat + Kp_pll * error;
end

In practice, a PLL requires careful gain selection and may include a second-order filter for zero steady-state error. The demodulated output is the filtered error signal (phase deviation). For a detailed implementation, refer to the MATLAB PLL tutorial.

Practical Considerations and Extensions

Effect of Modulation Index on Bandwidth

The modulation index (or phase deviation constant) kp determines whether the PM signal is narrowband (NBPM) or wideband (WBPM). In NBPM (kp < 0.5 rad), the spectrum occupies roughly twice the message bandwidth; in WBPM, the bandwidth can be approximated by Carson’s rule: BW ≈ 2(Δθ + 1)fm, where Δθ = kp·Am is the peak phase deviation in radians. Engineers often use WBPM to trade power for bandwidth, but this increases susceptibility to noise.

Comparison with Frequency Modulation

While PM and FM are closely related (FM can be considered the integral of PM), their noise performance differs. PM is more affected by amplitude variations in the channel, whereas FM is more robust against additive noise. In MATLAB, FM can be simulated by integrating the message signal before phase modulation:

% FM from PM using integration
m_int = cumtrapz(t, m_t);   % Integral of message
fm_signal = cos(2*pi*fc*t + kf * m_int); % kf is frequency deviation

This relationship is useful for switching between modulation types.

Digital Phase Modulation (PSK)

Phase modulation is the basis for digital phase shift keying (PSK), such as BPSK and QPSK. MATLAB provides pskmod and pskdemod for digital implementations. The continuous-time PM simulation presented here can be extended to digital symbols by using a rectangular or raised-cosine pulse shaping filter. For example:

% BPSK using pskmod
data = randi([0 1], 100, 1);        % Random binary data
bpsk_sym = pskmod(data, 2);         % BPSK symbols (0 or pi phase)
% Then modulate onto carrier (analog) -- often combined.

Exploring digital PM in MATLAB typically involves the pskmod documentation and link to a Wikipedia article on PSK.

Noise and Channel Effects

To test the robustness of PM, add additive white Gaussian noise (AWGN) using awgn:

SNR_dB = 10;                 % Signal-to-noise ratio in dB
s_t_noisy = awgn(s_t, SNR_dB, 'measured');
% Then demodulate the noisy signal to see degradation.

Plot the demodulated output at different SNRs to observe threshold effects. For low SNR, the phase unwrapping step may fail, leading to impulse noise. This behavior can be analyzed using bit error rate (BER) simulations when using digital PM.

Practical Applications

Phase modulation systems are ubiquitous:

  • Satellite communications – PM offers constant envelope, which is power-efficient for nonlinear amplifiers.
  • Radar systems – Phase-coded waveforms (e.g., Barker codes) exploit phase transitions for range resolution.
  • Data transmission – Phase shift keying (PSK) is the backbone of modern WiFi, cellular, and satellite links.
  • Software-defined radio – MATLAB’s SDR support (e.g., USRP) enables real‑time PM transmission and reception.

The simulations shown in this tutorial form the foundation for understanding and prototyping these systems.

Conclusion

Implementing phase modulation in MATLAB is a straightforward process that reinforces the theoretical relationship between a message signal and its phase-modulated carrier. By defining the message, applying a phase deviation, and optionally demodulating, engineers can explore the effects of modulation index, bandwidth, and noise on system performance. The code presented here is fully functional and can be adapted for advanced studies such as digital PSK, frequency modulation comparison, or PLL design. For further exploration, refer to the MATLAB Hilbert Transform documentation and the Communications Toolbox PM example.