필터 지우기
필터 지우기

Date array to timestamp

조회 수: 1 (최근 30일)
Peter Borda
Peter Borda 2015년 4월 9일
답변: per isakson 2020년 11월 4일
Hello!
I have an n x 1 cell array read from a file with date info in each cell, like this:
DateValues = {'13:22:32';'13:22:42';'13:22:52';'13:23:02';}
What I would like to have is a vector with the time spent between the subsequent dates. I used this piece of code for converting the strings into number.
TimeStamp = cell2mat(cellfun(@(x) datenum(x,'HH:mm:ss'),DateValues,'UniformOutput',false));
The resulting array seems correct and I can easily generate the difference of two neighbouring values. However, what I receive, are values like 1.1574e-4, although from the read date values I can clearly see that the differences should be around 10 seconds.
Any idea how to solve the problem?

답변 (1개)

per isakson
per isakson 2020년 11월 4일
Doc says: "The datenum function creates a numeric array that represents each point in time as the number of days from January 0, 0000. "
10 seconds is 10/(24*60*60) days

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by