extract numbers from cell array
Show older comments
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!
Accepted Answer
More Answers (2)
Andrei Bobrov
on 10 May 2014
A1 = regexp(A,'[\d*\.]*\d*','match')
A2 = [A1{:}]
out = str2double(strcat(A2{:}))
A simple version:
A = {'jdldi'; 'jdks5.4555h'; 'f67'}
S = cat(2, A{:});
S(isletter(S)) = [];
The simpler the code, the less chances to insert a bug.
1 Comment
Sebastian Lopez
on 19 Apr 2023
Thanks Jan! I wasn't aware of the isletter function
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!