Can't add a Greek letter into sprinf

Hi,
I am having problem with adding \angle character into my sprintf command. The result is for command window only.
Here is the line I need to add the character to:
out = arrayfun(@(x, y) sprintf('%f \angle %7.4f°', x, y), absA, phaseA, 'uni', 0);

 Accepted Answer

Angle is not a greek character.
You are trying to use tex with command window output. That will not work. Unicode might work if you are using an appropriate font.
anglechar = char(8736);
out = arrayfun(@(x, y) sprintf('%f %s %7.4f°', anglechar, x, y), absA, phaseA, 'uni', 0);

5 Comments

Thanks. It had to be like below though:
out = arrayfun(@(x, y) sprintf('%f %s %7.4f°', x, anglechar, y), absA, phaseA, 'uni', 0);
But that was the solution.
Yes, sorry about the typo.
Rafael Fehér
Rafael Fehér on 18 Sep 2020
Edited: Rafael Fehér on 18 Sep 2020
Walter, what If I would like to writte a greek letter using sprintf()?
I'm trying:
"eq_beta = sprintf('\beta = (%.2f) e/D² + (%.2f) e/D + (%.2f)',beta_fit(1),beta_fit(2),beta_fit(3));
text(1.0,0.75,eq_beta)"
but '\beta' seems not to work.
SOLVED: Using '\\beta' works out fine! I will leave my comment here if anyone else in the future have the same question.
Thank you very much for the tip on using double-/ (//beta)
Yes thank you. Been having that problem for awhile and couldn't figure it out

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!