write superscript in string
106 次查看(过去 30 天)
显示 更早的评论
Hello all,
I'm trying to show my R squared as a title but i wan 2 to be as a superscript not just R2. Here's my inputs:
R2 = 0.75;
t = sprintf('R^2 = %0.2f',R2);
title(t)
this gives me
t = 'R2 = 0.75'
but what I want is R superscript 2.
2 个评论
Cris LaPierre
2022-5-31
Same result, perhaps a little simpler.
R2 = 0.75;
title(['R^2 = ' num2str(R2)])
采纳的回答
the cyclist
2022-5-31
编辑:the cyclist
2022-5-31
It could be the interpreter. Does this work for you?
R2 = 0.75;
t = sprintf('R^2 = %0.2f',R2);
title(t,'interpreter','tex')
Also, it might be relevant to know what this returns for you:
get(groot,'defaultTextInterpreter')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!