maintain 0 at the start of a number
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Paul Murphy
le 11 Déc 2017
Réponse apportée : Star Strider
le 11 Déc 2017
I have string of numbers that starts with a 0. I need to convert this to a number (str2num) but maintain the 0 at the start, as it represents a phone number.
example:
>> a = ('0123')
a =
0123
>> b = str2num(a)
b =
123
Any suggestions on how to do this so that my answer would be 0123?
0 commentaires
Réponse acceptée
Star Strider
le 11 Déc 2017
Try this:
a = ('0123');
b = sprintf('%04u', uint64(str2num(a)))
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Numeric Types 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!