How to make this string a = '(0 0 0)' into a double b = [0 0 0]?
3 次查看(过去 30 天)
显示 更早的评论
Suppose I don't know what are the number inside the a string, it could be:
a = '(12 2.8 1.22)' % each number is separated by a single space
which should then be:
b = [12 2.8 1.22]
0 个评论
采纳的回答
更多回答(1 个)
Fangjun Jiang
2022-8-5
编辑:Fangjun Jiang
2022-8-5
a = '(12 2.8 1.22)';
b=sscanf(a,'(%f %f %f)')
b=transpose(sscanf(a,'(%f %f %f)'))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!