Hi, I can't figure out how to get fprintf() to display "r^2" without the "^". I have
fprintf("R^2; %.4f%s%.4f\n", gof.rsquare)
but this displays the "^". How do I fix this?

 採用された回答

Star Strider
Star Strider 2024 年 10 月 22 日

0 投票

Using ‘char(178)’ is an option —
gof.rsquare = 0.975;
fprintf("R"+char(0178)+"; %.4f%s%.4f\n", gof.rsquare)
R²; 0.9750
.

1 件のコメント

Aquatris
Aquatris 2024 年 10 月 23 日
編集済み: Aquatris 2024 年 10 月 23 日
alternatively using unicodes (U+00B2 is superscript 2, ..B9 is superscript 1 etc);
gof.rsquare = 0.975;
fprintf("R\xB2; %.4f%s%.4f\n", gof.rsquare)
R²; 0.9750
fprintf("R\xB9; %.4f%s%.4f\n", gof.rsquare)
R¹; 0.9750

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeNumeric Types についてさらに検索

タグ

質問済み:

cwp
2024 年 10 月 22 日

編集済み:

2024 年 10 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by