From vector to shorter vector of means in Matlab
Suppose I have a vector x
in Matlab of size 1000. I want to create a vector of y
length 10, where each component contains on average 100 entries from the vector x
.
My attempt is pretty simple
for i=1:10
y(i) = mean(x((1:100)+(i-1)*100));
end
I wonder if there is an assembly in the team or a more elegant solution for this.
+3
source to share