How can I select numbers from excel to matlab?

3 visualizaciones (últimos 30 días)
Mario Delle Cave
Mario Delle Cave el 20 de Abr. de 2021
Respondida: David Hill el 20 de Abr. de 2021
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 comentarios
David Hill
David Hill el 20 de Abr. de 2021
Attach your file.
Mario Delle Cave
Mario Delle Cave el 20 de Abr. de 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

Iniciar sesión para comentar.

Respuestas (1)

David Hill
David Hill el 20 de Abr. de 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

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by