Filter löschen
Filter löschen

Find specific datenum in Matrix

2 Ansichten (letzte 30 Tage)
David du Preez
David du Preez am 8 Jun. 2017
Bearbeitet: Andrei Bobrov am 8 Jun. 2017
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

Akzeptierte Antwort

David du Preez
David du Preez am 8 Jun. 2017
Bearbeitet: Andrei Bobrov am 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

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by