zeros before a string using num2str
Afficher commentaires plus anciens
I would like to pad zeros before a string. I have the following code:
a1 = 12.1521;
a2 = 2.1521;
b1 = num2str(a1,'%03.4f');
b2 = num2str(a2,'%03.4f');
The result is b1 = '12.1521';
The result is b2 = '2.1521';
I would like to obtain the result b1 = '012.1521' and b2 = '002.1521'
Réponse acceptée
Plus de réponses (2)
Catégories
En savoir plus sur Characters and Strings 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!