string to num
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Titus Edelhofer
2011-12-7
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 个评论
更多回答(1 个)
osman
2011-12-7
use str2num
2 个评论
Sean de Wolski
2011-12-7
That won't work. He'd going to need to parse the string based on '(,:' first
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!