How can I select numbers from excel to matlab?

3 views (last 30 days)
Hi, I have an excel file with only 1 column and every cell results as follows:
'2019-10-12T02:41:27.091Z,1/0669958925:52238,-5.9858581261e-02,-1.7725070822e-04,+1.1940838453e-03'
In order to pass from excel to matlab i wrote the following:
[num,str]=xlsread('file1');
num is empty, str is a Nx1 cell. Each cell is a char like the following I wrote before.
How can I extrapolate the last 3 numbers and the date at the beginning of this char? Thank you for the help!
  2 Comments
Mario Delle Cave
Mario Delle Cave on 20 Apr 2021
Sorry David but I can't attach the file, It's an excel file with only a coloumn and every cell is formed as follows:
2019-10-12T02:41:27.091Z,1/0669958925:52238,-5.9858581261e-02,-1.7725070822e-04,+1.1940838453e-03

Sign in to comment.

Answers (1)

David Hill
David Hill on 20 Apr 2021
str=readcell('test.xlsx');
%str={'2019-10-12T02:41:27.091Z,1/0669958925:52238,-5.9858581261e-02,-1.7725070822e-04,+1.1940838453e-03'}
for k=1:length(str)
T(1,:)=[regexp(str{k},'\d{4}[-]\d{2}[-]\d{2}','match'),regexp(str{k},'[+-]\d+[.]\d+[e][-]\d+','match')];
end

Categories

Find more on Data Import from MATLAB 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!