How can I split up several numbers in one cell from an excel file?
Show older comments
Dear Matlab-Community,
I want to import an excel file with 9 numbers in one cell separated by a comma. I need this data to be split up and written in 9 columns.
For example:
Input:
0,565.24,18.3882,0,69.1582,0,15.68,0,0
1,582.69,18.3895,0,64.1595,0,15.33,0,0
... and so on.
Could somebody help me with this?
Thanks in advance!
Domi
Accepted Answer
More Answers (2)
Dominik Kümpflein
on 14 Feb 2019
1 vote
4 Comments
madhan ravi
on 14 Feb 2019
Try reading the file using readtable()
Dominik Kümpflein
on 14 Feb 2019
madhan ravi
on 14 Feb 2019
Attach your data.
Dominik Kümpflein
on 14 Feb 2019
Bob Thompson
on 14 Feb 2019
0 votes
[~,~,data] = xlsread('myexcel.xlsx',range);
data = cellfun(@(x) str2num(x),data);
This is a first crack at the code. I'm not absolutely certain that the cellfun will work as I want it to, since I haven't tested it. Basically, you are going to read all of the cells of the excel file into a matlab cell array. I expect that the cells with multiple numbers will be treated as a string, but using str2num should convert them into actual number arrays for you.
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!