Average of 3d matrix

조회 수: 2 (최근 30일)
Lilya
Lilya 2020년 6월 9일
댓글: mohamad shirgholami 2020년 12월 14일
Hi All,
I have 3D matrix with dimension (61,57,273) the 273 is daily time. 39 weeks has 273 days.
I want to do a weekly average overtime to get (61,57,39).
result = reshape(data,61,57,39,7);
Data_mean = nanmean(result,4);
I am not sure about the reshaping. Any help would be appreciated to correct or suggest another way to do the average.
  댓글 수: 1
mohamad shirgholami
mohamad shirgholami 2020년 12월 14일
I have 3D matrix with dimension (61,57,365) the 365 is daily time. I want to do a monthly average overtime to get (61,57,12). But the number of days each month is different. I would be grateful for your help

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

채택된 답변

Walter Roberson
Walter Roberson 2020년 6월 9일
result = reshape(data,61,57,7,39);
Data_mean = permute(nanmean(result,3), [1 2 4 3]) %permute gets rid of the singleton dimension that results
  댓글 수: 1
Lilya
Lilya 2020년 6월 9일
Thank you very much!!

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

추가 답변 (0개)

카테고리

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