Select Folders with a certain date/time range

We have a folder filled with 1000's of folders with different names which we run analysis on. How can I make it so that i am able to filter folders from a certain date range/time range to do the analysis on. We currently have it setup where it can only select folders from a specific date. We use dir to fine the folders from a specific date but want to expand the capabilties of our script.

 采纳的回答

Use datetime arrays and date and time relational calculations.
D = dir(fullfile(matlabroot, 'toolbox', 'matlab', 'demos'));
D(4)
ans = struct with fields:
name: 'AgeVerificationCallback.m' folder: '/MATLAB/toolbox/matlab/demos' date: '23-Apr-2014 16:21:58' bytes: 382 isdir: 0 datenum: 7.3571e+05
inThePastWeek = D(4).date > datetime('today')-calweeks(1) % false
inThePastWeek = logical
0
onOrAfterStartOf2014 = D(4).date > datetime(2014, 1, 1) % true
onOrAfterStartOf2014 = logical
1

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by