Main Content

comm.DifferentialEncoder

Encode binary signal using differential coding

Description

The comm.DifferentialEncoder System object™ encodes the binary input signal within a channel. The output is the logical difference between the current input element and the previous output element. For more information, see Algorithms.

To encode a binary signal using differential coding:

  1. Create the comm.DifferentialEncoder 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?

Creation

Description

diffenc = comm.DifferentialEncoder creates a default differential encoder System object. This object encodes a binary input signal by calculating its logical difference with the previously encoded output signal.

example

diffenc = comm.DifferentialEncoder(Name=Value) sets properties using one or more name-value arguments. For example, comm.DifferentialEncoder(InitialCondition=5) sets the initial condition of the differential encoder to 5.

diffenc = comm.DifferentialEncoder(initcond) creates a differential encoder object with InitialCondition set to initcond. For example, when initcond is set to 1, this syntax creates the differential encoder object and sets the initial value used to generate initial output to 1.

Properties

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.

Initial value used by the encoder to generate initial output, specified as a scalar value. The object treats nonbinary values as binary, interpreting nonzero values as 1.

Data Types: double | logical

Usage

Description

Y = diffenc(X) encodes the input message using the differential encoding scheme and returns the binary encoded message, Y. For more information, see Algorithms.

Input Arguments

expand all

Input message, specified as a scalar or column vector. The object treats nonbinary inputs as binary signals.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | fiobject

Output Arguments

expand all

Differentially encoded message, returned as a binary-valued scalar or column vector. This output signal has the same dimensions and data type as that of input X.

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:

release(obj)

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

Examples

collapse all

Create a differential encoder System object.

diffEnc = comm.DifferentialEncoder;

Generate random binary data.

data = randi([0 1],6,1);

Differentially encode the random sequence, with InitialCondition property set to its default value, that is, 0.

encData = diffEnc(data)
encData = 6×1

     1
     0
     0
     1
     0
     0

Now set the value of InitialCondition property to 3.

diffEnc.release();
diffEnc.InitialCondition = 3;

Differentially encode the same random sequence and compare the output.

encData2 = diffEnc(data)
encData2 = 6×1

     0
     1
     1
     0
     1
     1

Algorithms

The comm.DifferentialEncoder output is the logical difference between the current input element and the previous output element. More specifically, the input and output are related by:

  • d(i1) = m(i1) XOR lastOutput (==InitialCondition property value for first input element)

  • d(ik) = m(ik) XOR d(ik-1), for k = 2:inputLen

  • lastOutput = d(ik)

where:

  • m is the input message.

  • d is the differentially encoded output.

  • ik is the kth element.

  • inputLen is the length of m.

  • lastOutput is the last element of d.

  • XOR is the logical exclusive-or operator.

Extended Capabilities

Version History

Introduced in R2012a

See Also

Objects

Blocks