how do I fprintf a power?

조회 수: 9 (최근 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 CenterFile Exchange에서 2-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