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?

 Akzeptierte Antwort

Star Strider
Star Strider am 22 Okt. 2024

0 Stimmen

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

1 Kommentar

Aquatris
Aquatris am 23 Okt. 2024
Bearbeitet: Aquatris am 23 Okt. 2024
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

cwp
am 22 Okt. 2024

Bearbeitet:

am 23 Okt. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by