Why am I unable to display certain characters in the upper ASCII range in the title of my plot in MATLAB 7.0 (R14)?

16 views (last 30 days)
When I execute the following command in MATLAB 7.0 (R14):
title(char([129 130 131]),'fontname','wingdings')
I receive a title in which the first character is correctly displayed (a one with a circle around it), but the next two characters appear as empty rectangles. This same command works in MATLAB 6.5.1 (R13SP1) and earlier versions.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
Constructs like the one in the example that use the char[] syntax are strongly discouraged for the following reasons:
1. The code is not portable. The availability of a particular font varies among platforms, and its encoding may also vary, even on the same platform.
2. While MATLAB guarantees the character set is unicode, it does not guarantee a particular encoding. MATLAB may change encoding in future releases.
A MATLAB user suggests the NATIVE2UNICODE function can be used as a workaround to convert an ASCII set of bytes to unicode characters, as in the following:
title(native2unicode([129 130 131]),'fontname','wingdings')
Type "doc native2unicode" at the MATLAB prompt to see the documentation for this function.

More Answers (1)

Karthick SK
Karthick SK on 25 Aug 2021
Edited: Karthick SK on 25 Aug 2021
In 'Windows' machine it does not work. Select symbols from Matlab default fonts like 'ZapfDingbats' to achieve the goal.
Important thing to note is that you need to give the 'char' command in hexadecimal.
For example,
text(0.5,0.5,char(065),'fontname','ZapfDingbats','fontsize',20); % char in decimal code
prints the corresponding ZapfDingbats character, whereas
text(0.4,0.5,char(0x2721),'fontname','ZapfDingbats','fontsize',20); % char in hexadecimal code
prints the corresponding ZapfDingbats graphic text.
The relevant decimal and hexadecimal values can be found in the following links:
Use the table given in the Unicode blocks for ‘Zapf Dingbats’ .
  1. https://en.wikipedia.org/wiki/Zapf_Dingbats
  2. https://help.adobe.com/en_US/framemaker/2015/using/using-framemaker-2015/Appendix/frm_character_sets_cs/frm_character_sets_cs-5.htm
(Credits: Kannan Munusamy. My friends found this way as efficient and the credits go to him)


Find more on Environment and Settings 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!