how do I fprintf a power?

8 ビュー (過去 30 日間)
cwp
cwp 2024 年 10 月 22 日
編集済み: Aquatris 2024 年 10 月 23 日
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 日
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 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by