Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to print unicode text or characters in MATLAB?

Is it possible to print some characters like 'ح' (U+062D) as the title of an image in a subplot?

like image 949
Jalal Avatar asked Aug 10 '11 16:08

Jalal


1 Answers

Using some Java as described by Yair Altman on undocumentedmatlab.com, you can add HTML-aware labels to your plot. You can therefore put your Unicode character 'ح' (U+062D) into such a label using the &#xHEXCODE; syntax, in your case ح:

figure;
labelStr = '<html>&#x062D;</html>';
jLabel = javaObjectEDT('javax.swing.JLabel',labelStr);
[hcomponent,hcontainer] = javacomponent(jLabel,[100,100,40,20],gcf);

This should display an empty figure window which just contains that single Unicode character. Tested on Matlab R2010b with WinXP.

For more information about tricking MATLAB into displaying Unicode, see this SO post which might in parts be specific to OS X.

Note that a few characters which are not available in your current character set can be available through the native LaTex capabilities of MATLAB title() as discussed here; however this is far from covering all of Unicode.

like image 118
Jonas Heidelberg Avatar answered Oct 05 '22 15:10

Jonas Heidelberg