Date to vector error

1 view (last 30 days)
Kendal
Kendal on 18 Nov 2022
Commented: Campion Loong on 18 Nov 2022
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 Comments
Jan
Jan on 18 Nov 2022
@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 on 18 Nov 2022
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."

Sign in to comment.

Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!