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

조회 수: 2 (최근 30일)
Ali Nouri
Ali Nouri 2020년 2월 11일
댓글: Steven Lord 2020년 2월 14일
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??

채택된 답변

Stephen23
Stephen23 2020년 2월 11일
>> 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
Ali Nouri
Ali Nouri 2020년 2월 14일
Thanks.
Steven Lord
Steven Lord 2020년 2월 14일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by