subtracting a number from string
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
how i can subtract a number from string ?
for example :
subject1_EO - i want to extract only number one..
1 commentaire
Réponses (2)
Star Strider
le 21 Mai 2019
One approach:
str = 'subject1_EO';
nrc = regexp(str, '\d+', 'match')
nr = str2double(nrc{:})
producing:
nrc =
1×1 cell array
{'1'}
nr =
1
2 commentaires
Stephen23
le 21 Mai 2019
+1 a cunning use of a comma-separated list combined with the demand-driven output of nested functions. Explicit indexing is clearer though:
nr = str2double(nrc{1})
Voir également
Catégories
En savoir plus sur Characters and Strings 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!