How do I Append a Time Stamp?

2 Ansichten (letzte 30 Tage)
Matt Brown
Matt Brown am 13 Feb. 2017
Beantwortet: Walter Roberson am 13 Feb. 2017
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?

Antworten (1)

Walter Roberson
Walter Roberson am 13 Feb. 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 );

Community Treasure Hunt

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

Start Hunting!

Translated by