How to count how many numbers there are in a string?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
Basically I have in a script:
I need Matlab to say '3' in this example.
Any ideas?
2 Commenti
Guillaume
il 11 Gen 2015
What is the definition of 'a number'? Are 123.456, 1e7, 4*i numbers? Or is it just integers?
Risposta accettata
Più risposte (1)
Azzi Abdelmalek
il 11 Gen 2015
str='a b c 45 3 2'
out=numel(regexp(str,'\d+','match'))
3 Commenti
Ced
il 20 Gen 2015
That's because these are the only two functions there. You can find a list and description of the different input arguments of e.g. regexp in the documentation: Regexp Documentation
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!