greek symbols in disp command

hi I have a disp command disp('x y z') and I would like to insert a greek letter in the text any way of doing it? Thanks Renzo

 Accepted Answer

disp('θ')
works fine for me.

6 Comments

the question was just on how to insert theta!
I fail to see the problem.
disp(char(911:950))
If you are using a newer version of MATLAB and you are using a PC or Mac, and your locale is not set to en_* (English), then you can use any handy keyboard method to insert unicode characters into your .m file and expect to have them saved and retrieved when you load the file. But be sure to test on a sample first before you rely on this.
This does not work if your locale is set to English: in that case MATLAB does not save the .m file as UTF-8.
Using the char() code should work on OS-X for any reasonably new version. However, on MS Windows there can be font problems.
See http://unicode.org/charts/PDF/U0370.pdf for the official greek character chart. Note though that the positions given there are in hex notation such as 0398 is hex 0x0398 . char() expects decimal. The table at http://sites.psu.edu/symbolcodes/languages/ancient/greek/greekchart/ gives decimal entity numbers or you can use
char(hex2dec('0398'))
ok for dispaying a single character but how to insert the character in a string like disp('xxxxx theta yyyy')?? thanks renzo
You could concatenate
disp(['beginning ' char(955) ' end'])
Please accept the answer that best solves your problem
thank you it works! renzo

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!