필터 지우기
필터 지우기

How to take an average every four columns?

조회 수: 5 (최근 30일)
Chameleon17
Chameleon17 2018년 2월 13일
댓글: Chameleon17 2018년 2월 15일
Hi, I have seen similar questions but I am getting stuck altering the code for what I want. I have a matrix of (64 x 18144), each row is a met station and each column is a 15 minute data measurement - I want to convert this to hourly data for each station - so I want to have an output matrix of (64 x 4536). I have seen some solutions but I don't have the 'tools' they require. Any help/ideas would be very much appreciated! :)
  댓글 수: 1
Chameleon17
Chameleon17 2018년 2월 15일
Thank you for both your answers! they worked! :)

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

채택된 답변

James Tursa
James Tursa 2018년 2월 13일
x = your 64x1844 matrix
result = reshape(mean(reshape(x.',4,[])),size(x,2)/4,[]).';

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2018년 2월 13일
편집: Andrei Bobrov 2018년 2월 13일
A - your matrix (64 x 18144)
B = A.';
[m,n] = size(B);
t = minutes((0:m)'*15);
Tb = array2timetable(B,'RowTimes',t);
Tout = retime(Tb,'hourly','mean');
out = Tout{:,:}';

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by