What are other types of messages than warnings and errors?

17 views (last 30 days)
So far I have been using just two methods for messaging to inform the user during the run of a script: The warning() function:
and the error() function:
They both give simple yet noticeable coloured messages. But at the same time they also contain prefixes Warning and Error using ... (line ...).
I was therefore wondering if there are other methods/functions for messaging that can be quickly sent to the screen during a script? Maybe a neutral message in, say, blue colour that is neither a warning nor an error but simply a note() or message() or FYI() or similar?
Alternatively, are the warning() and error() messages generally editable so I can remove/alter the prefixes?

Answers (1)

Stephen23
Stephen23 on 9 Feb 2018
Edited: Stephen23 on 9 Feb 2018
There is no documented way to get arbitrarily colored text in the command window. The only documented features with colored text are error (red), warning (orange), and by adding a hyperlink (blue):
Actually hyperlinks are more versatile than most users realize, and are sadly underutilized:
To get text in any arbitrary color you could download and use Yair Altman's excellent FEX submission cprintf, which relies on some undocumented functionality and features of MATLAB:
Thus you can simply create your own message using whatever color you want, and even define it in a function called note, message, or whatever. Note that cprintf is not supported by the MATLAB documentation and could break, so use it at your own risk.
Yair Altman's blog explaining the development of cprintf is definitely worth reading:

Categories

Find more on Migrate GUIDE Apps 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!