Date to vector error

1 次查看(过去 30 天)
Kendal
Kendal 2022-11-18
I am getting the following error:
"Error using datevec The input to DATEVEC was not an array of character vectors or strings."
when trying to run the following code:
%extract date information from the bicycle dataset;
date = EcoTotemBroadwayBicycleCount1(:,1);
% convert to numberic array to search through
dateNum = datevec(date);
  3 个评论
Jan
Jan 2022-11-18
@Kendal: Think twice. As the cyclist has mentioned already, the error message is clear. The readers cannot know, what the contents of EcoTotemBroadwayBicycleCount1 is, but you can check this.
By the way, "EcoTotemBroadwayBicycleCount1" is a really bad choice for the name of a variable. Names are not the right place to tell a story, because this impedes the readability and increases the risk of typos.
Campion Loong
Campion Loong 2022-11-18
Echo suggestions to attach data, and preferrably more code, to help the community help you. Other than that, do prefer using datetime to represent time points. Also see datevec documentation for the same recommendation:
"While you can represent dates and times as date vectors, it is recommended that you use datetime values to represent points in time, and duration or calendarDurationvalues to represent elapsed times."

请先登录,再进行评论。

回答(0 个)

类别

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