Warning does not display message after message identifier
2 views (last 30 days)
Show older comments
MathWorks Support Team
on 28 Jan 2016
Edited: MathWorks Support Team
on 3 Mar 2021
Why does "warning" not print out the message after a message identifier?
Compare the following:
>> warning('A:B:div0','0/0 operation encountered, converted to nan.') Warning: 0/0 operation encountered, converted to nan.
>> warning('A:B:0div0','0/0 operation encountered, converted to nan.') Warning: A:B:0div0
Accepted Answer
MathWorks Support Team
on 3 Mar 2021
Edited: MathWorks Support Team
on 3 Mar 2021
Each field of the message identifier must start with a letter. In the example above, the last field of the identifier starts with a number, so MATLAB does not recognize it as a valid identifier and instead treats it as a message. The function is then called with the syntax,
>> warning(msg,A1,...,An)
where "msg" is treated as a formatted string. However, the message does not contain any formatting conversion characters (%s, %d, etc.) so the remaining argument is not displayed.
Please refer to the link below for details about the message identifier syntax:
0 Comments
More Answers (0)
See Also
Categories
Find more on Argument Definitions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!