Find specific datenum in Matrix

1 view (last 30 days)
Hi. I have a 14x14 (A)matrix.In column 1 are datenum values corresponding to a random hour of a day. I want to use these datenum values to find the hourly data in a much larger matrix(B) and then create a new matrix with the hourly data using the dates from A. So the new matrix should be 336x14

Accepted Answer

David du Preez
David du Preez on 8 Jun 2017
Edited: Andrei Bobrov on 8 Jun 2017
% extract dates
dates = datevec(SON_CS2_lowTCO(1:14,1));
% Remove h,m,s
dates = dates(:,1:3);
dates23 = dates;
% Add end of day to matrix
dates23(:,4)=23;
dates23(:,5)=0;
dates23(:,6)=0;
for i=1:14
findA2 = CS2_All(:,1) >=datenum(dates(i,1:3)) & CS2_All(:,1)<= datenum(dates23(i,1:6));
A2(24*i-23:24*i,:) = CS2_All(findA2,:);
end

More 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!