![]() First, Notepad does not understand any kind of formatting other than basic text. Changing Matlab's Command Window colors – part 2 – The Matlab Command Window enables a limited degree of inline color customization - this post describes how to use it.If you want to use fprintf in Matlab to generate formatted output to a file that can be read by Notepad, there are a few things you need to be aware of.This post describes the changes and the implementation details. EditorMacro v2 – setting Command Window key-bindings – The EditorMacro utility was extended to support built-in Matlab Editor and Command-Window actions and key-bindings.Changing Matlab's Command Window colors – Matlab's Command Window foreground and background colors can be modified programmatically, using some of Matlab's undocumented internal Java classes.Command Window text manipulation – Special control characters can be used to format text output in Matlab's Command Window.cprintf – display formatted color text in the Command Window – cprintf is a utility that utilized undocumented Matlab desktop functionalities to display color and underline-styled formatted text in the Command Window.Bold color text in the Command Window – Matlab Command Window text can be formatted *bold* since R2011b.If, however, you require your outputs to be a bit more lively, then consider using cprintf:ĭo you know of any additional undocumented Command Window hack? If so, please do leave a comment below. In their shoes, I’d probably have extended the paradigm with something like or: (I wonder where I got this idea from? hmm…) Maybe I’m just being too harsh: it’s obviously easier to bitch from the benches than to score at the field…Īnyway, if you only need black, red and orange colors in your text, you need look no further than fprintf. Moreover, the [\b hack does not enable multiple segments of orange colors in the same text, a natural extension. If tomorrow a green color or underlined text will be needed, they’ll need to modify the hard-coding and extend it with yet new hard-coding. If you ask me, this is an example of bad design: instead of modifying fprintf to enable generic color and text formatting, the developer hard-coded a specific [\b hack for a specific color, and a different specific hack for bold formatting. Note the related FEX utility tcprintf, which implements ANSI sequences for color-coding the Matlab console output. ![]() In those old days, we used the ESC-[ sequence to add text formatting to the console text. The [\b sequence is reminiscent of the CSI ANSI sequence used in days of yore, on non-graphic consoles. Since ‘\b’ translates into the BS character, we can directly use char(8), as follows:ĭisp ( ' 8 ' text' ] )ĭisp(' 8 ' text']) MathWorks made the hack very specific so that it would be close to impossible to come by it by mistake. By the way, it won’t work if you use any other combination, or if there are not exactly two such in the displayed text. The \b hack relies on the fact that \b is actually the standard back-space control-character (BS, or ASCII 8), which erases the preceding \b couple. Of course, we can still use cprintf to display any color in the rainbow, orange included: By redirecting STDOUT, Carsten was able to see that by adding '\b' to the output text, anything between the brackets was given an orange color. This is similar to the bypass that I explained last year, for the bold formatting. ![]() While errors have for ages been rendered red by the simple act of directing their output to STDERR, warnings are output to STDOUT and so a bypass was naturally devised. This made sense: after all, recent releases have started to display warnings as orange text on STDOUT. I followed this up last year with the relatively new ability to display bold text formatting, using either fprintf or cprintf.Ī short while ago, Carsten Allefeld (a regular on this blog) alerted me to the fact that recent Matlab releases have added yet another undocumented feature, this time the ability to specify orange formatting to the output text. ![]() Back in 2009, I explained the undocumented ability to display red or hyperlinked text using fprintf, or co lo red and underlined text using my cprintf utility. Matlab’s Command Window text is notorious for its boring black & white appearance when sending output via the built-in fprintf or disp commands. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |