MATLAB Answers

Ricardo Prada

Displaying (in the prompt) latin characters, such as á, é, í, ó, ú, and ñ, using MATLAB R2010b/R2011a for mac

Asked by Ricardo Prada
on 26 Apr 2011
Latest activity Answered by Anandakumar Selvaraj on 27 Feb 2014

Hi MATLAB community.

How can we display (in the prompt) latin characters, such as á, é, í, ó, ú, and ñ, using MATLAB R2010b/R2011a for mac (last iteration of Snow Leopard, 10.6.7)?

For example, when trying to run this script on MATLAB for mac

fprintf('Química, Matemáticas, Español.\n')

the prompt throws me

Qu?mica, Matem?ticas, Espa?ol.

which does not contain any of the latin characters I entered on my script, but those question marks as a replacement.

Any help will be greatly appreciated. Thank you.

P.S. 1: I am using an Apple Western Spanish keyboard to enter those latin characters.

P.S. 2: By prompt I am referring to the MATLAB Command Window.


3 Answers

Answer by Andrew Newell
on 26 Apr 2011

You could try changing the locale.

EDIT: I found a better solution:

fprintf(native2unicode('Química, Matemáticas, Español.','latin1'))

The output is:

Química, Matemáticas, Español.>>

I looked at this command earlier but didn't use it in the right way. You said you wanted a prompt, so I took out the \n.



unicode2native('Química, Matemáticas, Español.','latin1')

ans =

Columns 1 through 19

81 117 26 109 105 99 97 44 32 77 97 116 101 109 26 116 105 99 97

Columns 20 through 30

115 44 32 69 115 112 97 26 111 108 46

give me the same result. The same happens when using other alias, such as: 'latin2', 'latin3', and 'latin4'. MATLAB throws me the same result.

I though the same... most likely the 2007 Apple Western Spanish Keyboard is the problem. In such a case, I will try contacting the MATLAB Support so they may give me some workaround to solve my problem. Again, thank you very much for your kind of help.

At least I can do it on my machine now! Good luck.

Answer by Andrew Newell
on 28 Apr 2011

Maybe I have been missing the embarrassingly obvious:

disp('Química, Matemáticas, Español.')


By changing only the locale (from "Colombia (English)" to "United States") there was no effect; so I decided to delete some preferences, and boom!, as simple as that, worked!

I wonder if perhaps it was stuck on a particular output font...

Hi Walter, at this point, I think it is tough to know. But most likely you are right.

Answer by Anandakumar Selvaraj on 27 Feb 2014

Try this in your code

 feature('DefaultCharacterSet', 'UTF8') %# for all Character support

or try 'Windows-1250' insted UTF8

'Windows-1250' for Central European languages that use Latin script, (Polish, Czech, Slovak, Hungarian, Slovene, Serbian, Croatian, Romanian and Albanian)

Note:- that UTF-8 can be used for all languages and is the recommended charset on the Internet.


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!