Why the function mean does not return only one plot rather than 31?
1 view (last 30 days)
Show older comments
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
REE=xlsread('REE_perfiles2020.xlsx',1,'a3:h8786');
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)
0 Comments
Accepted Answer
Jan
on 18 Dec 2020
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)
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!