bio_img_pick

Pick of the Week

Recognizing outstanding contributions from the MATLAB ecosystem

cprintf – Easy display of formatted colored text in Command Window

Mike's pick this week is cprintf by Yair Altman.
I recently took a deep dive into some new MATLAB functionality that allows you to use ANSI escape sequences to display formatted text using the built in fprintf command. While the syntax used is standard, it's also arcane!
Yair Altman's cprintf command uses ANSI escape escape sequences under the hood on modern versions of MATLAB and provides a user-friendly way of specifying the formatting. However, it also works on older versions of MATLAB too using alternative techniques and has been in use for many years with over 30,000 downloads at the time of writing.
I'm using MATLAB R2026b so can easily install it using mpminstall
mpminstall("cprintf",Prompt=false)
You will be accessing content made available under separate license terms. License terms are available in the package installation folder. The following packages will be installed: cprintf@1.23.0 (Repository: File Exchange Repository) Fetching package 'cprintf@1.23.0' ...Done. Extracting package 'cprintf@1.23.0' ...Done. Successfully installed the following packages: cprintf@1.23.0 (help) Installation complete.
I'll defer to the File Exchange page for full details of everything that cprintf can do but here are a few examples
|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.