extract numeric values from strings in xls files?
1 view (last 30 days)
Show older comments
Hi,
I have an xls file with 10 columns. The columns are full of string and inside the strings there are some numeric values that I need to extract and put in a new column. I was thinking to do something like this:
load doc.txt %to load the file in txt format
for i=1:total lines of txt
read each line
take numeric values
put in table
end
I don't even know if any from above is possible in matlab. Is it possible to read strings and from them extract the numeric values?
0 Comments
Answers (1)
Walter Roberson
on 19 Nov 2011
You can use regexp() and str2double()
Note: if the values are floating point numbers that might be in exponential format, then it is fairly difficult to construct a correct regexp pattern that will match such numbers properly. When working with such numbers, it is much easier if there is a delimiter such as space or comma.
0 Comments
See Also
Categories
Find more on Environment and Settings 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!