matlab - moving mean on a circle -


is there way calculate moving mean in way values @ beginning , @ end of array averaged ones @ opposite end?

for example, instead of result:

a=[2 1 2 4 6 1 1]; movmean(a,2) ans = 2.0 1.5 1.5 3.0 5 3.5 1.0 

i want obtain vector [1.5 1.5 1.5 3 5 3.5 1.0], initial array element 2 averaged ending element 1.

generalizing arbitrary window size n, how can add circular behavior movmean in way want:

movmean(a([(end-floor(n./2)+1):end 1:end 1:(ceil(n./2)-1)]), n, 'endpoints', 'discard') 

for given a , n = 2, get:

ans =  1.5000    1.5000    1.5000    3.0000    5.0000    3.5000    1.0000 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -