I have an array of strings:
dd = {'L','temp1','temp23','Reas'};
I would like to extract the numbers from the strings that contain any numbers (if that makes sense). So, the solution for this question should be 1 and 23.
How can I achieve this in matlab?
解决方案
Here's part of the solution. Suppose
myString = 'temp23'
then the expression
str2double(a(isstrprop(a,'digit')))
will return
23
I haven't got the time to turn this into a function to deal with your array of strings but this should get you started.
@DennisJahruddin suggested the following completion of my answer. I haven't tested it thoroughly:
dd = {'L','temp1','temp23','Reas'};
ee = cellfun(@(a) str2double(a(isstrprop(a,'digit'))),dd);
ff = ee(~isnan(ee))