extract numbers from cell array
104 次查看(过去 30 天)
显示 更早的评论
hello!
i have this cell array wich may have many cells,and not only three as here.
A = {'jdldi'; 'jdks5.4555h'; 'f67'}
i want to extract only the numbers,and show them as one number
for this example i want the result to be 5.455567
any help please?
Thank you very much!
采纳的回答
Azzi Abdelmalek
2014-5-10
A = {'jdldi'; 'jdks5.4555h'; 'f67'}
b=regexp(A,'\d+(\.)?(\d+)?','match')
out=str2double([b{:}])
3 个评论
Azzi Abdelmalek
2014-5-10
编辑:Azzi Abdelmalek
2014-5-10
A = {'jdldi'; 'jdks5.4555h'; 'f67'}
b=regexp(A,'\d+(\.)?(\d+)?','match')
out=strjoin([b{:}],'')
更多回答(2 个)
Andrei Bobrov
2014-5-10
A1 = regexp(A,'[\d*\.]*\d*','match')
A2 = [A1{:}]
out = str2double(strcat(A2{:}))
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!