Yearly average but keeping matrix dimensions

Hello
I am trying to compute the yearly average of a 365x121x240 array.
What I used to do before is:
average=nanmean(mat,1);
squeezenan=squeeze(mat,1);
This will give me the average but in a matrix with dimensions 121x240.
But in this case, I want to take the average of the 365 days, while keeping the new matrix dimensions as 365x121x240.

댓글 수: 2

For the moment, let's ignore the 3rd dimension.
Suppose matrix is this:
mat = [1 2;
4 5];
The mean along the 1st dimension is
average = [2.5 3.5];
How would you have wanted the 1st dimension treated, if you had wanted it to stay length 2? Did you want
average = [2.5 3.5
2.5 3.5];
?
redlush
redlush 2020년 3월 10일
Yes, I would essentially just repeat the average.

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

답변 (1개)

the cyclist
the cyclist 2020년 3월 10일

0 개 추천

repavgmat = repmat(mean(mat,1),[size(mat,1) 1 1]);

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2020년 3월 9일

답변:

2020년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by