MATLAB Answers

Subset timetable by specific time windows/periods

4 views (last 30 days)
Louise Wilson
Louise Wilson on 25 May 2020
Edited: Louise Wilson on 25 May 2020
I have a large dataset which looks like this:
The first column is datetimes and the first row is frequency bins. The data is dB values. (1,1) is irrelevant and could be 0/NA...
I then have a table of datetimes:
where the first column is the associated datetime variable from the large dataset, second is sunrise, third is end of dawn, fourth is beginning of dusk, and fifth is sunset. The first row is irrelevant and if possible I would change it to useful variable names.
I would like to subset the large dataset using these values.
For example, if the datetime (2,1) in the dataset falls between either duskdawntime(2,2:3) or duskdawntime (2,4:5), I would like to take the corresponding row of data from the large dataset and store it in a separate dusk or dawn table. Since these time windows change every day, it is important that each row of data is distinct i.e. we compare row 2 filename with row 2 sunrise time and row 2 sunset time.
(I calculated end of dawn and beginning of dusk by adding/removing 1hr from sunrise/sunset times but I may change the size of this window)
So far, I am thinking something like this:
dawnoutput=[]; %new empty arrays for dawn and dusk
for i=1:filenumber %where filenumber is the data row, changes on each iteration
filename=times(filenumber,1); %datetime of filename from first column in datetime matrix
if (filename >= sunrise) && (filename <= dawnend)
elseif (filename >= dawnend) && (filename <= sunset)
...but I am not sure if this is the most refined way.
Is this possible? Thanks in advance for any suggestions/help

Answers (0)




Community Treasure Hunt

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

Start Hunting!