How do I Append a Time Stamp?
Afficher commentaires plus anciens
I have a spreadsheet containing a data file that has a time saved with hh:mm:ss in one columun then milliseconds in a second column. Can anyone clue me in on how to combine these to give a time stamp that shows hh:mm:ss:fff after I have read it into Matlab?

Réponses (1)
Walter Roberson
le 13 Fév 2017
[~, ~, raw] = xlsread('YourFile.xlsx');
tcol = raw(3:end, 1); %pull out appropriate column
mscol = raw(3:end, 2); %pull out appropriate column
assert(ischar(tcol{1}), 'Expected the time column to be character format');
if ischar(mscol{2}))
mscol = num2cell( str2double(mscol) );
end
mscol_num = cell2mat(mscol);
mscol_char_cell = cellstr( num2str( mscol_num, ':%03d') );
combined = strcat( tcol, mscol_char_cell );
Catégories
En savoir plus sur Language Fundamentals dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!