write superscript in string

127 ビュー (過去 30 日間)
azarang asadi
azarang asadi 2022 年 5 月 31 日
コメント済み: azarang asadi 2022 年 6 月 1 日
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
Cris LaPierre 2022 年 5 月 31 日
Same result, perhaps a little simpler.
R2 = 0.75;
title(['R^2 = ' num2str(R2)])
azarang asadi
azarang asadi 2022 年 6 月 1 日
it didn't work, maybe it's my release? it's 2020b

サインインしてコメントする。

採用された回答

the cyclist
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')
  1 件のコメント
azarang asadi
azarang asadi 2022 年 6 月 1 日
Thank you, it worked!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by