필터 지우기
필터 지우기

Datenum date conversion troubles

조회 수: 1 (최근 30일)
Aaron
Aaron 2012년 7월 31일
I have a matlab file of timestamps called d that looks like this...
'7/31/2012 2:35:00 PM'
'7/31/2012 2:36:00 PM'
'7/31/2012 2:37:00 PM'
'7/31/2012 2:38:00 PM'
'7/31/2012 2:39:00 PM'
'7/31/2012 2:40:00 PM'
and I am trying to put these timestamps into matlab so I can graph the data. so I have tried
CR100.time = datenum(d(:,1),'mm/dd/yyyy HH:MM:SS Ww')
But I am getting the response...
??? Error using ==> datenum at 182 DATENUM failed.
Caused by: Error using ==> dtstr2dtnummx Failed on converting date string to date number.
Any clue how to import these timestamps?
Also do you know how I can save an excel file in a matlab script.
  댓글 수: 1
the cyclist
the cyclist 2012년 7월 31일
편집: the cyclist 2012년 7월 31일
Is d a cell array of strings?

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

답변 (3개)

the cyclist
the cyclist 2012년 7월 31일
편집: the cyclist 2012년 7월 31일
I suspect it is the 'Ww' that is tripping you up. Try
datenum(d,'mm/dd/yyyy HH:MM:SS PM')

Thomas
Thomas 2012년 7월 31일
Just try something like:
str={'7/31/2012 2:35:00 PM'
'7/31/2012 2:36:00 PM'
'7/31/2012 2:37:00 PM'
'7/31/2012 2:38:00 PM'
'7/31/2012 2:39:00 PM'
'7/31/2012 2:40:00 PM'}
date_time=datenum(str)

Aaron
Aaron 2012년 7월 31일
I just tried that and I get
??? Error using ==> datenum at 182 DATENUM failed.
Caused by: Error using ==> dtstr2dtnummx Failed on converting date string to date number.
  댓글 수: 3
Aaron
Aaron 2012년 7월 31일
sorry. d is a data structure of the type {} in the matlab workspace. It is only one column with many rows filled with strings like the ones posted previously.
the cyclist
the cyclist 2012년 7월 31일
My advice would be to use my code on subset of d [such as d(1:5), then d(6:10), etc] until you can identify some entries of d that are causing the problem.

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

카테고리

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