# Why the function mean does not return only one plot rather than 31?

조회 수: 1 (최근 30일)
Tony Castillo 2020년 12월 18일
댓글: Tony Castillo 2020년 12월 18일
Dear Coders,
I have an issue I am trying to obtain only one profile per month, so I want to make a day-average per month, but when I apply the function "mean" it does not calculate the row by row average, it gives me back the same 31 days, please, tell me what it is wrong in this simple operation. I share the code below.
clear all
close all
NDias=REE(:,1); %%%%%Número de días en total
aP=REE(:,4); %
ai=reshape(aP,[24, 366]);
E=ai(:,[1:31]);
ME=mean(E,24);
plot(ME)
legend
size(ME)

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

### 채택된 답변

Jan 2020년 12월 18일
mean(E, 24) calculates the mean over the 24th dimension. Remember that in Matlab all arrays are assume to have and arbitrary number of trailing dimensions of the size 1:
x = [2, 3; 4, 5]
x(1,2, 1,1,1,1,1,1,1,1,1,1,1,1,1,1) % Valid!
You want to bild the mean over the 2nd dimension, if I understand you correctly. Then:
mean(E, 2)
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Tony Castillo 2020년 12월 18일

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

### 카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

R2019b

### Community Treasure Hunt

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

Start Hunting!

Translated by