write superscript in string

조회 수: 125 (최근 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 CenterFile Exchange에서 String에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by