extract numbers from cell array
105 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
alex
am 10 Mai 2014
Kommentiert: Sebastian Lopez
am 19 Apr. 2023
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!
2 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 10 Mai 2014
A = {'jdldi'; 'jdks5.4555h'; 'f67'}
b=regexp(A,'\d+(\.)?(\d+)?','match')
out=str2double([b{:}])
3 Kommentare
Azzi Abdelmalek
am 10 Mai 2014
Bearbeitet: Azzi Abdelmalek
am 10 Mai 2014
A = {'jdldi'; 'jdks5.4555h'; 'f67'}
b=regexp(A,'\d+(\.)?(\d+)?','match')
out=strjoin([b{:}],'')
Weitere Antworten (2)
Andrei Bobrov
am 10 Mai 2014
A1 = regexp(A,'[\d*\.]*\d*','match')
A2 = [A1{:}]
out = str2double(strcat(A2{:}))
0 Kommentare
Siehe auch
Kategorien
Mehr zu Numeric Types finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!