필터 지우기
필터 지우기

How to import date time format from excel

조회 수: 2 (최근 30일)
AKHILESH KUMAR
AKHILESH KUMAR 2016년 12월 2일
댓글: AKHILESH KUMAR 2016년 12월 4일
i have data in excel like
4:46:32 1.257375
5:16:32 1.286917
4:48:13 2.274518
5:03:13 2.274042
4:33:38 1.595688
4:48:37 1.591687
when i import this data into Matlab using xlsread, it looks like
0.198981481481482 1.257375
0.219814814814815 1.286917
0.200150462962963 2.274518
0.210567129629630 2.274042
0.190023148148148 1.595688
0.200428240740741 1.591687
but i want it in original format.
  댓글 수: 2
Jan
Jan 2016년 12월 2일
I've formatted your text to make it readable.
AKHILESH KUMAR
AKHILESH KUMAR 2016년 12월 4일
it's not working well. defines error in d=days(M(:,1)); d.Format='hh:mm:ss';

댓글을 달려면 로그인하십시오.

답변 (3개)

Star Strider
Star Strider 2016년 12월 2일
One approach is to re-convert them:
M = [0.198981481481482 1.257375
0.219814814814815 1.286917
0.200150462962963 2.274518
0.210567129629630 2.274042
0.190023148148148 1.595688
0.200428240740741 1.591687];
hmsv = datestr(datenum(M(:,1)), 'hh:mm:ss');
Mc = {hmsv, M(:,2)}; % Output Cell Array

Jan
Jan 2016년 12월 2일
편집: Jan 2016년 12월 2일
dv = datevec(0.198981481481482);
ds = sprintf('%d:%d:%d', dv(4:6))
This would insert a leading zero:
datestr(0.198981481481482, 13)
>> '04:46:32'

Peter Perkins
Peter Perkins 2016년 12월 2일
Or with durations and a table:
>> M = [0.198981481481482 1.257375
0.219814814814815 1.286917
0.200150462962963 2.274518
0.210567129629630 2.274042
0.190023148148148 1.595688
0.200428240740741 1.591687];
>> d = days(M(:,1)); d.Format = 'hh:mm:ss';
>> x = M(:,2);
>> t = table(d,x)
t =
d x
________ ______
04:46:32 1.2574
05:16:32 1.2869
04:48:13 2.2745
05:03:13 2.274
04:33:37 1.5957
04:48:37 1.5917

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by