Print Latex/Greek-Chars to Commandline

125 vues (au cours des 30 derniers jours)
Mark Whirdy
Mark Whirdy le 25 Juil 2013
Modifié(e) : Anurag Gupta le 21 Nov 2017
Is it possible to fprintf a string to commandline which includes latex characters (I know its possible on figures etc).
The below snippet doesn't work but maybe there's a clever workaround?
a = 45; fprintf(['\lambda=',num2str(a)])
Daniel below mentions a possible HTML to LaTeX workaround - does anyone have a solution in this vain?
  1 commentaire
Pietro
Pietro le 12 Déc 2015
Hi, sorry i'm a kinda late :). However i was looking for an answer to the same question and (since Matlab supports HTML code) i tried typing the following lines:
charlambda=char(955); %HTML numeric entity for lambda
a=45;
lambda_string=[num2str(charlambda),' = ', num2str(a),'\n'];sprintf(lambda_string)

Connectez-vous pour commenter.

Réponse acceptée

Mark Whirdy
Mark Whirdy le 26 Juil 2013
Mathworks support:
Thank you for contacting Mathworks.
The feature of typing Greek letter from MATLAB command line is not available in the current releases of MATLAB, this is because that MATLAB is using windows-1252 as its Default Character Set, and from the link below you will see the Greek letters are not included in this Character Set.
<https://en.wikipedia.org/wiki/Windows-1252>
For more reading about this topic, you can refer to the link below:

Plus de réponses (1)

Daniel Shub
Daniel Shub le 25 Juil 2013
Yes and no. The commandline does not have a LaTeX interpreter so so you cannot pass it LaTeX code. The commandline does handle HTML so if you can go from LaTeX to HTML you can get there. For your case the workaround is simplier:
a = 45; fprintf(['λ=',num2str(a), '\n'])
  9 commentaires
Mehmet Mahmudoglu
Mehmet Mahmudoglu le 24 Nov 2016
Modifié(e) : Mehmet Mahmudoglu le 24 Nov 2016
This code only works for command line but not from m file if you use it in m file you have to use
a = 45; fprintf([num2str(char(955)),' = ',num2str(a), '\n'])
Anurag Gupta
Anurag Gupta le 21 Nov 2017
Modifié(e) : Anurag Gupta le 21 Nov 2017
why not from .m file?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Labels and Annotations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by