Main Content


Demodulate using CPFSK method and Viterbi algorithm


The comm.CPFSKDemodulator System object™ demodulates a signal that was modulated using the continuous phase frequency shift keying (CPFSK) method. The input is a baseband representation of the modulated signal.

To demodulate a signal that was modulated using the CPFSK method:

  1. Create the comm.CPFSKDemodulator object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?



cpfskDemod=comm.CPFSKDemodulator creates a demodulator System object. This object demodulates the input CPFSK-modulated data using the Viterbi algorithm.

cpfskDemod=comm.CPFSKDemodulator(Name=Value) creates a CPFSK demodulator object and sets properties using one or more name-value arguments. For example, comm.CPFSKDemodulator(InitialPhaseOffset=pi/4,TracebackDepth=25), configures the object with an initial phase offset of pi/4 radians and a Viterbi algorithm traceback depth of 25.


cpfskDemodcomm.CPFSKDemodulator(M,Name=Value) creates a CPFSK demodulator object with the ModulationOrder property set to M, and optional name-value arguments.


expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Size of the symbol alphabet, specified as a power-of-two integer scalar.

Option to provide output data as bits, specified as a numeric or logical 1 (true) or 0 (false).

  • When you set this property to false, the output is an (N / SamplesPerSymbol) long column vector containing integers in the range [–(M–1), (M–1)]. N is the number of input baseband modulated symbols (specifically, the length of the input signal). M represents the value of the ModulationOrder property.

  • When you set this property to true, the output is a binary column vector of a length equal to P×(N / SamplesPerSymbol). The output contains length-P bit words, where P = log2(M). In this scenario, the object first maps each demodulated symbol to an odd integer value, K, in the range [–(M–1), (M–1)]. The object then maps K to the nonnegative integer (K+M–1)/2. Finally, the object maps each nonnegative integer to a length-P bit word, using the mapping that you specify in the SymbolMapping property.

Symbol encoding, specified as 'Binary' or 'Gray'. This property determines how the object maps each demodulated integer symbol value to a P-length bit word, where P = log2(M) and M represents the ModulationOrder property. The integer symbol values are in the range [0, M].

  • When you set this property to 'Binary', the object uses binary-coded ordering.

  • When you set this property to 'Gray', the object uses Gray-coded ordering.


This property applies when you set the BitOutput property to true.

Modulation index, specified as a scalar, h, or a column vector, [h0, h1, …. hH–1]. H–1 represents the length of the column vector.

  • When hi varies from interval to interval, the object operates in multi-h.

  • When the object operates in multi-h, hi must be a rational number.

Initial phase offset in radians, specified as a numeric scalar.

Number of samples per input symbol, specified as a positive, integer scalar.

Traceback depth for the Viterbi algorithm, specified as a positive, integer scalar. The value of this property is also the value of the output delay. That value is the number of zero symbols that precede the first meaningful demodulated symbol in the output.

Data type of the output, specified as

  • 'double','int8', 'int16', or 'int32', when you set the BitOutput property to false.

  • 'double' or 'logical', when you set the BitOutput property to true.



Y = cpfskDemod(X) demodulates the input signal by using the CPFSK method.

Input Arguments

expand all

Modulated input signal, specified as a column vector with a length equal to an integer multiple of the number of SamplesPerSymbol.

Data Types: double | logical | int8 | int16 | int32

Output Arguments

expand all

Demodulated output signal, returned as a column value or a matrix.

  • When you set BitOutput to false, the output is a column vector of integer symbols.

  • When you set BitOutput to true, the output is a matrix of bits, with each row containing a bit-word symbol.

To specify the output data type, use the OutputDataType property.

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:


expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object


collapse all

Create a CPFSK modulator, an AWGN channel, and a CPFSK demodulator. Configure the modulator and demodulator with modulation order set to 8, bit input, and Gray-encoded symbol mapping.

M = 8; % Modulation order
cpfskMod = comm.CPFSKModulator(M, ...
    BitInput=true, ...
awgnChan = comm.AWGNChannel( ...
    NoiseMethod='Signal to noise ratio (SNR)', ...
cpfskDemod = comm.CPFSKDemodulator(M, ...
    BitOutput=true, ...

Define the simulation parameters. Create an error rate calculator, accounting for the delay caused by the Viterbi algorithm that the CPFSK demodulator uses.

numFrames = 1000; % Number of frames transmitted
k = log2(M);      % Bits per symbol 
spf = 100;        % Symobls per frame

delay = log2(M)*cpfskDemod.TracebackDepth;
errorRate = comm.ErrorRate( ...
for counter = 1:numFrames
    data = randi([0 1],k*spf,1);
    modSignal = cpfskMod(data);
    noisySignal = awgnChan(modSignal);
    receivedData = cpfskDemod(noisySignal);
    errorStats = errorRate(data,receivedData);

fprintf('Error rate = %f\nNumber of errors = %d\n', ...
Error rate = 0.004247
Number of errors = 1274


expand all

For CPFSK, the phase shift per symbol is π × h, where h is the modulation index.


[1] Anderson, John B., Tor Aulin, and Carl-Erik Sundberg. Digital Phase Modulation. New York: Plenum Press, 1986.

Extended Capabilities

Version History

Introduced in R2012a