How to convert a 8760X30matrix to a 365X30 matrix?

1 visualización (últimos 30 días)
Ali Nouri
Ali Nouri el 11 de Feb. de 2020
Comentada: Steven Lord el 14 de Feb. de 2020
I have a 8760X30 matrix and I want to convert this matrix to 365X30 matrix.
Every values in the row indicates a value in hour and now by take average of every 24 values, I want to have the day matrix.
Can anybody help me with it??

Respuesta aceptada

Stephen23
Stephen23 el 11 de Feb. de 2020
>> inp = rand(8760,30); % fake data matrix
>> out = mean(permute(reshape(inp,24,[],30),[2,3,1]),3);
And checking:
>> size(out)
ans =
365 30
>> isequal(mean(inp(1:24,:),1),out(1,:))
ans = 1
  5 comentarios
Ali Nouri
Ali Nouri el 14 de Feb. de 2020
Thanks.
Steven Lord
Steven Lord el 14 de Feb. de 2020
Since this is time-based data, I'd recommend a timetable instead of a table as that would let you do things like retime the timetable to a daily basis with one function call.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by