Date to vector error
1 view (last 30 days)
Show older comments
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
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
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."
Answers (0)
See Also
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!