display comma in xlabel
Afficher commentaires plus anciens
Hi all
How can I change the format of the numbers in the x-axis to be like 10,000 instead of 10000?
number of rounds 10000 but I would like to display like 10,000.
How could I change it?
plot(1:Simulation,ooooo(2,:),'k-.');
title('PDR')
xlabel('Rounds');
ylabel('Time (ms)');
grid on
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 10 Août 2022
0 votes
Turn the number into a string. See my attached little utility function.
3 commentaires
My function handles those numbers perfectly:
v = [3141 31415 314159 3141592]
for k = 1 : numel(v)
str = CommaFormat(v(k))
end
Walter Roberson
le 11 Août 2022
The challenge is that the user does not want the comma for 3141 -- only for 10000 or more.
Image Analyst
le 11 Août 2022
@Walter Roberson oh, okay. In that case you'd have to put in a check for the number of digits being 5 or greater if he wanted to use that function.
Catégories
En savoir plus sur Grid Lines, Tick Values, and Labels dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!