extractRecent

Select most recent message from array of messages

Syntax

extracted = extractRecent(message)
extracted = extractRecent(message, messagename)
extracted = extractRecent(message, id, extended)

Description

extracted = extractRecent(message) parses the given array message and returns the most recent instance of each unique CAN message found in the array.

extracted = extractRecent(message, messagename) parses the specified array of messages and returns the most recent instance matching the specified message name.

extracted = extractRecent(message, id, extended) parses the given array message and returns the most recent instance of the message matching the specified ID with the specified standard or extended type.

Input Arguments

message

An array of CAN message objects that you specify to parse and find the specified messages by name or ID.

messagename

The name of the message that you specify to extract.

id

The id of the message that you specify to extract.

extended

Indicates whether the message ID is a standard or extended type. The Boolean value is true if extended and false if standard.

Output Arguments

extracted

An array of CAN message objects returned with the most recent instance of id found in the message.

Examples

msgOut = extractRecent(message)
msgOut = extractRecent(message, 'msg1')
msgOut = extractRecent(message, {'msg1' 'msg2' msg3'})
msgOut = extractRecent(message, 3000, true)
msgOut = extractRecent(message, [400, 5000], [false true])

More About

expand all

Tips

You can specify id as a vector of identifiers. For example, if you pass id in as [250 500], extractRecent returns the latest instance of both CAN message 250 and message 500 if it finds them in the message array. By default, all identifiers in the vector are standard CAN message identifiers unless extended is true. If any id in the vector is an extended type, then extended is true and is a vector of the same length as id.

Was this topic helpful?