Main Content

Analog Baseband Modulation Examples

These examples show basic workflows for analog baseband modulation and demodulation. Elements of the examples apply to other analog modulation techniques as well.

Note

The analog modulation Simulink® blocks in Communications Toolbox™ process only sample-based scalar signals. The analog modulator and demodulator accept real-valued input signals and return real-valued output signals. The analog demodulator blocks return discrete-time (not continuous-time) output.

Modulate and Demodulate Sinusoidal Signal Using FM Method

Modulate and demodulate a sinusoidal signal. Plot the demodulated signal and compare it to the original signal.

Initialize parameters for the example.

fs = 100;  % Sample rate (Hz)
ts = 1/fs; % Sample period (s)
fd = 25;   % Frequency deviation (Hz)

Create a sinusoidal signal with a duration of 0.5 s and frequency of 4 Hz.

t = (0:ts:0.5-ts)';
x = sin(2*pi*4*t);

Create an FM modulator System object™, setting the sample rate and frequency deviation. Then, create an FM demodulator System object, using the FM modulator configuration to set the demodulator properties.

fmmodulator = comm.FMModulator( ...
    'SampleRate',fs, ...
    'FrequencyDeviation',fd);
fmdemodulator = comm.FMDemodulator(fmmodulator);

FM-modulate the signal and plot the real component of the complex signal. The frequency of the modulated signal changes with the amplitude of the input signal.

y = fmmodulator(x);
plot(t,[x real(y)])
title('Input Sinusoid and FM-Modulated Signals')
xlabel('Time (seconds)'); ylabel('Amplitude')
legend('Input signal','Modulated signal (real component)')

Demodulate the FM-modulated signal.

z = fmdemodulator(y);

Plot the original and demodulated signals. The demodulator output signal exactly aligns with the original signal.

plot(t,x,'r',t,z,'ks')
legend('Original signal','Demodulated signal')
xlabel('Time (s)')
ylabel('Amplitude')

Modulate and Demodulate Streaming Audio Signals Using FM Broadcast Method

Modulate and demodulate an audio signal with the FM broadcast modulator and demodulator System objects. Plot the frequency responses to compare the input and demodulated audio signals.

Load the audio file guitartune.wav by using an audio file reader System object™. Set the samples per frame to 44,100, which is large enough to include the entire audio file.

audiofilereader = dsp.AudioFileReader("guitartune.wav", ...
    SamplesPerFrame=44100);
x = audiofilereader();

Create spectrum analyzer System objects to plot the spectra of the modulated and demodulated signals.

saFM = spectrumAnalyzer( ...
    SampleRate=152e3, ...
    Title="FM Broadcast Signal");
saAudio = spectrumAnalyzer( ...
    SampleRate=44100, ...
    ShowLegend=true, ...
    Title="Audio Signal", ...
    ChannelNames=["Input signal" "Demodulated signal"]);

Create FM broadcast modulator and demodulator objects. Set the sample rate of the output audio signal to match the sample rate of the input audio signal. Configure the demodulator to match the specified modulator.

fmbMod = comm.FMBroadcastModulator( ...
    AudioSampleRate=audiofilereader.SampleRate, ...
    SampleRate=200e3);
fmbDemod = comm.FMBroadcastDemodulator(fmbMod)
fmbDemod = 
  comm.FMBroadcastDemodulator with properties:

            SampleRate: 200000
    FrequencyDeviation: 75000
    FilterTimeConstant: 7.5000e-05
       AudioSampleRate: 44100
             PlaySound: false
                Stereo: false
                  RBDS: false

The length of the sequence input to the object must be an integer multiple of the decimation factor. To determine the audio decimation factor of the filter in the modulator and demodulator, use the info object function.

info(fmbMod)
ans = struct with fields:
       AudioDecimationFactor: 441
    AudioInterpolationFactor: 2000
        RBDSDecimationFactor: 19
     RBDSInterpolationFactor: 320

info(fmbDemod)
ans = struct with fields:
       AudioDecimationFactor: 50
    AudioInterpolationFactor: 57
        RBDSDecimationFactor: 50
     RBDSInterpolationFactor: 57

The audio decimation factor of the modulator is a multiple of the audio frame length of 44,100. The audio decimation factor of the demodulator is an integer multiple of the 200,000 samples data sequence length of the modulator output.

Modulate the audio signal and plot the spectrum of the modulated signal.

y = fmbMod(x);
saFM(y)

Demodulate the modulated audio signal and plot the resultant spectrum. Compare the input signal spectrum with the demodulated signal spectrum. The spectra are similar except that the demodulated signal has smaller high-frequency components.

z = fmbDemod(y);
saAudio([x z])

Modulate and Demodulate FM Signals in Simulink

Modulate and demodulate a sinusoidal signal using FM Modulator Baseband and FM Demodulator Baseband blocks.

The fmmoddemod model generates a sine wave of frequency 4 Hz and amplitude 1 V. The FM Modulator Baseband block sets the frequency deviation to 50 Hz.

The Modulated Signal scope shows that the frequency of the modulator output, Mod Sig, varies with the amplitude of the input data.

The Demodulated Signal scope demonstrates that the output of the demodulator, Demod Sig, is perfectly aligned with the input data.