Main Content

extractRecent

Select most recent CAN message from array of messages

Description

example

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 value and type.

Examples

collapse all

Extract most recent message for each name.

msgOut = extractRecent(msgs);

Extract recent messages for specific names.

msgOut1 = extractRecent(msgs,'DoorControlMsg');
msgOut2 = extractRecent(msgs,{'DoorControlMsg' 'WindowControlMsg'});

Extract recent messages with IDs 200 and 5000. Note that 5000 requires an extended style ID.

msgOut = extractRecent(msgs,[200 5000],[false true]);

Input Arguments

collapse all

CAN messages to parse, specified as an array of CAN message objects. This is the collection from which you extract recent messages.

Name of message to extract, specified as a character vector, string, or array that supports these types.

Example: 'DoorControlMsg'

Data Types: char | string | cell

ID of message to extract, specified as a numeric value or vector. Using this argument also requires that you specify an extended argument.

Example: [200 400]

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

Indication of extended ID type, specified as a logical true or false. Use a value true if the ID type is extended, or false if standard. This argument is required if you specify a message ID.

If the message ID is a numeric vector, use a logical vector of the same length for extended. For example, if you specify id and extended as [250 5000],[false true], then extractAll returns all instances of CAN messages 250 and 5000 found within in the message array.

Example: true

Data Types: logical

Output Arguments

collapse all

Extracted CAN messages, returned as an array of CAN message objects. These are the most recent messages matching the search criteria.

Version History

Introduced in R2009a

See Also

Functions