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)
Show older comments
Matias Holm Andersen
on 8 Jun 2015
Commented: Rena Berman
on 24 Jan 2017
2 Comments
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.
Accepted Answer
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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!