How do I Append a Time Stamp?

조회 수: 2 (최근 30일)
Matt Brown
Matt Brown 2017년 2월 13일
답변: Walter Roberson 2017년 2월 13일
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?

답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 13일
[~, ~, 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 );

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by