message

Creates a message object from a message identifier.

Category: Other public functions: lang

Syntax

m = message(id)

Looks up the message id in the message catalog.

m = message(id, a1, ..., aN)

Fills the placeholders of the message with the arguments.

Description

Message objects keep the identifier of a message separate from its text, which allows text to be looked up in a catalog, for example for translation. They can be passed to error and warning in place of a format string, and getString or string convert one to text.

An identifier that is not in the catalog is an error.

Input arguments

id
Message identifier of the form 'component:mnemonic', as text.
a1, ..., aN
Values that replace the numbered holes of the message text.

Output arguments

m
A message object with properties Identifier and Arguments. getString(m) returns the text.

Example

Message from the catalog

m = message('MATLAB:minrhs');
s = getString(m)
Output
s = 'Not enough input arguments.'

Notes

MatLivre has only a catalog of MATLAB's own messages; a custom identifier raises "Invalid Message ID format".

See also

error warning MException string