string to num
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I am reading string data of this format from a text file:
(20:200,40:300)
This is the area of an image which I wish to select. How do I convert this string to number range. Thanks.
Charles-
0 commentaires
Réponse acceptée
Titus Edelhofer
le 7 Déc 2011
Hi Charles,
a simple way would be replace all non digits by spaces and use str2num afterwards:
x = '(20:200,40:300)';
x(~isstrprop(x, 'digit')) = ' ';
xNumber = str2num(x)
Titus
12 commentaires
Plus de réponses (1)
osman
le 7 Déc 2011
use str2num
2 commentaires
Sean de Wolski
le 7 Déc 2011
That won't work. He'd going to need to parse the string based on '(,:' first
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!