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?

1 view (last 30 days)
  2 Comments
Guillaume
Guillaume on 9 Jun 2015
Do not edit away your question. It's really unfair to the people who spend time answering your question.
The original question was about reading the numbers in an excel spreadsheet, where some of them are preceded by letters.

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 8 Jun 2015
[~, ~, 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.

More Answers (0)

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!