Error using datenum (line 201) DATENUM failed.

조회 수: 3 (최근 30일)
Rachele Franceschini
Rachele Franceschini 2021년 11월 18일
댓글: Rachele Franceschini 2021년 11월 18일
Help me!
I have this error, and I don't know why.
Error using datenum (line 201)
DATENUM failed.
Caused by:
Error using dtstr2dtnummx
Failed to convert from text to date number.
My script is this:
[ndata, text, alldata]=xlsread('positive_read_Copia.xlsx'); % inside there are data (dd/mm/yyyy hh:mm:ss) and coordinates
date=date.';
tmp=char(date);
tmp_date=datenum(tmp,'dd/mm/yyyy HH:MM');
DateVector = datevec(tmp_date);
Date_minute=(tmp_date-tmp_date(1))*24*60; % Time, in minutes compared to the 1st georeferenced tweet
clear tmp;
  댓글 수: 2
Cris LaPierre
Cris LaPierre 2021년 11월 18일
Please share your spreadsheet. You can attach it using the paperclip icon.
Rachele Franceschini
Rachele Franceschini 2021년 11월 18일
Done!

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

답변 (1개)

Stephen23
Stephen23 2021년 11월 18일
편집: Stephen23 2021년 11월 18일
Do not use outdated, discouraged, deprecated DATENUM (or for that matter DATEVEC or DATESTR).
Import your data using READTABLE, which automatically identifies the dates and imports them as DATETIME objects:
T = readtable('positive_read_Copia.xlsx')
T = 1108×3 table
tweet_created_at Latitude Longitude ____________________ ________ _________ 28-Sep-2020 01:13:00 4.8186 45.728 28-Sep-2020 02:11:00 -80.217 25.783 28-Sep-2020 03:20:00 4.4894 45.895 28-Sep-2020 08:38:00 -74.245 40.617 28-Sep-2020 09:32:00 4.0817 44.128 28-Sep-2020 09:46:00 4.0817 44.128 28-Sep-2020 10:20:00 103.45 35.845 28-Sep-2020 10:22:00 4.0817 44.128 28-Sep-2020 10:41:00 2.5067 49.098 28-Sep-2020 11:55:00 6.8992 49.53 28-Sep-2020 12:34:00 15.314 -4.3317 28-Sep-2020 12:50:00 35.25 32 28-Sep-2020 13:46:00 -14.75 16.5 28-Sep-2020 14:05:00 2 47 28-Sep-2020 14:36:00 7.4167 43.733 28-Sep-2020 16:24:00 9.2167 45.617
Then your task is much easier too, simply subtract to get the differences as DURATION objects:
D = T.tweet_created_at - T.tweet_created_at(1)
D = 1108×1 duration array
00:00:00 00:58:00 02:07:00 07:25:00 08:19:00 08:33:00 09:07:00 09:09:00 09:28:00 10:42:00 11:21:00 11:37:00 12:33:00 12:52:00 13:23:00 15:11:00 15:24:00 15:42:00 16:55:00 18:10:00 18:15:00 21:16:00 21:26:00 22:42:00 30:23:00 31:14:00 32:11:00 32:23:00 37:02:00 37:55:00
which is then trivial to convert into MINUTES:
M = minutes(D)
M = 1108×1
0 58 127 445 499 513 547 549 568 642
  댓글 수: 4
Rachele Franceschini
Rachele Franceschini 2021년 11월 18일
Error is: I have the map and the graph empty.

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

카테고리

Help CenterFile Exchange에서 Time Series Objects에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by