MATLAB: How to extract a number from a string array

extract numbersstr2double

I have a string array of values that look like this: "(164) (165)" "(165) (166)" "(165) (166)" How can extract the first three digit value only so that I get a matrix that is 164 165 165

Best Answer

"How can extract the first three digit value only so that I get a matrix that is 164 165 165"
With a simple application of regexp and str2double:
>> C = {'(164) - (165)','(165) - (166)','(165) - (166)'};
>> str2double(regexp(C,'\d{3}','match','once'))
ans =
164 165 165