Effacer les filtres
Effacer les filtres

write superscript in string

75 vues (au cours des 30 derniers jours)
azarang asadi
azarang asadi le 31 Mai 2022
Commenté : azarang asadi le 1 Juin 2022
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 commentaires
Cris LaPierre
Cris LaPierre le 31 Mai 2022
Same result, perhaps a little simpler.
R2 = 0.75;
title(['R^2 = ' num2str(R2)])
azarang asadi
azarang asadi le 1 Juin 2022
it didn't work, maybe it's my release? it's 2020b

Connectez-vous pour commenter.

Réponse acceptée

the cyclist
the cyclist le 31 Mai 2022
Modifié(e) : the cyclist le 31 Mai 2022
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 commentaire
azarang asadi
azarang asadi le 1 Juin 2022
Thank you, it worked!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by