Borrar filtros
Borrar filtros

Find specific datenum in Matrix

1 visualización (últimos 30 días)
David du Preez
David du Preez el 8 de Jun. de 2017
Editada: Andrei Bobrov el 8 de Jun. de 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

Respuesta aceptada

David du Preez
David du Preez el 8 de Jun. de 2017
Editada: Andrei Bobrov el 8 de Jun. de 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

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by