I have a 1x8760 matrix (hours per year). I need to add up 24h and make a 1x365 or 365x1 matrix.
example: sum of values ​​1-24 in 1x1
sum of values ​​25-48 in 1x2 ..

 Respuesta aceptada

Star Strider
Star Strider el 16 de En. de 2021
Try this:
M = 1:8760; % Create Vector
Mr = reshape(M, 24, []); % Reshape Vector
MeanMr = mean(Mr); % Take Column Means
.

3 comentarios

Nikola Ostojic
Nikola Ostojic el 16 de En. de 2021
Editada: Nikola Ostojic el 16 de En. de 2021
Thanks, thanks, thanks!!!
I lost 3 hours with the "for" function
note: instead of mean I need sum (column summation, not average)
I resolved with "sum"
Star Strider
Star Strider el 16 de En. de 2021
Sorry. I misread your Question. Replace mean with sum. They operate the same way.
Star Strider
Star Strider el 16 de En. de 2021
As always,. my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Preguntada:

el 16 de En. de 2021

Comentada:

el 16 de En. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by