Mean neighbour values of a vector
Show older comments
Hi,
I got an original data(a vector, size is 1*N):
the format is like this: 𝑠1:𝑥1,𝑥2,𝑥3…𝑥𝑁
And I need 20 series,
The scale 2 series was obtained by averaging two successive values from the original series. Scale 3 was obtained by averaging every three original values and so on as shown in equation.
𝑠2:(𝑥1+𝑥2)/2,(𝑥3+𝑥4)/2,…,(𝑥𝑁−1+𝑥𝑁)/2
𝑠20:(𝑥1+⋯+𝑥20)/20,…,(𝑥𝑁−20+⋯+𝑥𝑁)/20
How can I achieve this in Matlab?
1 Comment
Ameer Hamza
on 18 Nov 2020
Suppose you have an odd number of elements? How to calculate s2 in that case? For example, x have 5 elements.
s2 =: (x1+x2)/2, (x3+x4)/2, x5+????
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!