datenum(ye​ar,month,d​ay,hr) that returns integer

2 views (last 30 days)
Chris Hooper
Chris Hooper on 13 May 2022
Commented: Chris Hooper on 14 May 2022

I need a datenum(year,month,day,hr) that returns an integer, where year, month, day, and hr are vectors of integers.
motivation: I am trying to do this for fast lookup of many dates in a large table, where each row contains data for an hourly sample. Therefor the output of datnum will become the indices of a sparse matrix containing the row indices of the original table of data.

Accepted Answer

dpb on 13 May 2022
Wrong approach.
Instead, convert the table to a timetable; there are direct, builtin functions to return by rowtimes either individual records or those matching a time span, etc., ...

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by