how to find the position of a given number
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
if the input is 1050, whats the code to get the position of 5.....(answer is third)
0 commentaires
Réponses (3)
Image Analyst
le 5 Sep 2012
locationOf5 = strfind('1050', '5')
You can adapt it to other numbers, or pass in string variables instead of hard-coding it if you want.
3 commentaires
Image Analyst
le 6 Sep 2012
locationOfDigit = strfind(num2str(yourFullNumber), num2str(yourDesiredDigit))
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!