Take the mean over multiple points in plot
Afficher commentaires plus anciens
I want to calculate the mean over multiple points in a plot.
y = [12 17 16 15 56 45 24 86 65 41];
x = length(y);
now I want the mean over the first two points the second two points etc. But my real dataset is bigger than these 10 points so I need a loop for it, but don't know how to do it.
Réponses (1)
Torsten
le 1 Oct 2018
0 votes
mean(reshape(y,2,numel(y)/2))
4 commentaires
jj27
le 1 Oct 2018
I guess that the number of element in y is an odd number. This conflicts with your averaging.
Try
Z=[mean(reshape(y(1:end-1),2,numel(y(1:end-1))/2)),y(end)]
jj27
le 1 Oct 2018
Torsten
le 1 Oct 2018
Is the lenghth of the y-array divisible by 60 ? What do you want to do if this is not the case ?
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!