MATLAB: How can i get the numbers from an Excel document? like if we have L/22, and we want to get the number 22 out

Best Answer

  • [~, ~, raw] = xlsread('somefile.xlsx'); %read raw content of excel file
    numtext = regexp(raw, '\d+', 'match', 'once'); %extract 1st sequence of digits of each cell
    numbers = cellfun(@str2double, numtext) %convert strings to numbers.
    will do it, assuming that the numbers are all integers (otherwise the regular expression has to be more complex).
    Alternatively, create a new table in excel with a formula that creates a copy of the data while stripping the non-numeric characters and import that table in matlab.