필터 지우기
필터 지우기

Find specific datenum in Matrix

조회 수: 1 (최근 30일)
David du Preez
David du Preez 2017년 6월 8일
편집: Andrei Bobrov 2017년 6월 8일
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

채택된 답변

David du Preez
David du Preez 2017년 6월 8일
편집: Andrei Bobrov 2017년 6월 8일
% 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by