Main Content


Unpack signal data from CAN message



value = unpack(message,startbit,signalsize,byteorder,datatype) takes a set of input parameters to unpack the signal value from the message and returns the value as output.


collapse all

Unpack the data value from a CAN message.

Unpack a 16-bit integer value.

message = canMessage(500,false,8);
value = unpack(message,0,16,'LittleEndian','int16')
value =



Unpack a 32-bit single value.

value = unpack(message,0,32,"LittleEndian",'single')
value =



Unpack a 64-bit double value.

value = unpack(message,0,64,'LittleEndian','double')
value =


Input Arguments

collapse all

CAN message, specified as a CAN message object, from which to unpack the data.

Example: canMessage

Signal starting bit in the data, specified as a single or double value. This is the least significant bit position in the signal data. Accepted values for startbit are from 0 through 63, inclusive.

Example: 0

Data Types: single | double

Length of the signal in bits, specified as a numeric value. Accepted values for signalsize are from 1 through 64, inclusive.

Example: 16

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

Signal byte order format, specified as 'LittleEndian' or 'BigEndian'.

Example: 'LittleEndian'

Data Types: char | string

Data type of unpacked value, specified as a character vector or string. The supported values are 'uint8', 'int8', 'uint16', 'int16', 'uint32', 'int32', 'uint64', 'int64', 'single', and 'double'.

Example: 'double'

Data Types: char | string

Output Arguments

collapse all

Value of message data, returned as a numeric value of the specified data type.

Version History

Introduced in R2009a