How to include Markers in a string for title of a plot
Show older comments
I tried using the following command:
ttl = sprintf(' R1 = %0.2f and \x22D2 %s = %0.2f (in Consistent Units)', var(1), str(1),var(2) );
Then, I use ttl as title(ttl). However, MATLAB does not recognize the UNICODE character and prints simply a blank square. However, If I separately use sprintf('\x22D2') in command window, I can see the correct unicode character. Why does this happen and how to resolve it?
Accepted Answer
More Answers (1)
Possibly you have set the default Interpreter on titles to 'latex'
var = rand(2,1);
str = "Hi there!";
ttl = sprintf(' R1 = %0.2f and \x22D2 %s = %0.2f (in Consistent Units)', var(1), str(1),var(2) );
title(ttl, 'Interpreter', 'none')
1 Comment
var = rand(2,1);
str = 'Hi there!';
ttl = sprintf(' R1 = %0.2f and \x22D2 %s = %0.2f (in Consistent Units)', var(1), str(1),var(2) );
subplot(3,1,1)
hT=title(ttl, 'Interpreter', 'none');
hT.Interpreter
subplot(3,1,2)
hT=title(ttl, 'Interpreter', 'tex');
hT.Interpreter
subplot(3,1,3)
hT=title(ttl, 'Interpreter', 'latex');
hT.Interpreter
They all seem to display the same although the 'LaTeX' does produce a warning message. OP didn't mention getting any errors or warnings, just that the symbol wasn't rendered. Of course, that doesn't prove didn't, agreed...
I presume that when LaTeX errors internally it reverts to another choice but doesn't change the state of the 'Renderer' property that could cause other valid LaTeX sequences to fail is why it ends up displaying the same text as either 'none' or 'tex'
A pretty quick and far from thorough search makes it appear there is no universal way to display unicode characters in LaTeX and given that one cannot add packages into the MATLAB embedded version, it would appear that that choice is not one to pick, anyway.
As above, I think it will be the font OP is using doesn't support the particular glyph...but we don't know what is using...
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


