color in output in matlab

130 vues (au cours des 30 derniers jours)
ali hassan
ali hassan le 5 Fév 2022
Commenté : Walter Roberson le 14 Nov 2024 à 0:42
let say if i want my output for certain condition in red or green clor,can it be done so?
a=[1 2 3 4 4];
b=[1 2 3 4 5];
if any(abs(a-b))==1
sprintf('ali')
end
what should i add so that it will print 'ali' in red?
  3 commentaires
jessupj
jessupj le 14 Nov 2024 à 0:16
is that really still the state of the art? it seems like there should be something much simpler than a 600ish line external function.
Walter Roberson
Walter Roberson le 14 Nov 2024 à 0:42
That is really still the state of the art. That contribution takes care to be compatible over a range of versions, and to support several different features.
You could always call com.mathworks.services.Prefs.setColorPref directly if you want.

Connectez-vous pour commenter.

Réponse acceptée

Arif Hoq
Arif Hoq le 5 Fév 2022
It might be helpful
a=[1 2 3 4 4];
b=[1 2 3 4 5];
if any(abs(a-b))==1
fprintf(2,'\n ali \n')
end
1 for default, 2 for red

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by