Double Sided Moving Average

3 views (last 30 days)
James Gay
James Gay on 26 Aug 2020
Edited: Matt J on 26 Aug 2020
Hello, I am trying to create a double sided moving average of my data that averages 9-points or whatever is avalible. Here is my code for the averaging so far.
ColitisMean = movmean (d2Colitis, [8 0]) ;
PColitisMean = plot (xRawColitis, ColitisMean, 'red'), hold on;
ControlMean = movmean (d2Control, [8 0]);
PControlMean = plot (xRawControl, ControlMean, 'blue') ;
set (gca, 'xdir', 'reverse');
xlim([400 4000]);
xlabel ('wavelength cm^-^1');
ylabel ('Averaged Second Derivative');
legend ({'Colitis', 'Control'}, 'Location', 'best') ;
I am trying to figure out how to get it to follow the pattern of
Y = (a,b,c,d,e,f,g,h……..z) (i.e. total set of data =26) <- original data
Y’ = (a’, b’, c’, d’, …… z’) <- what I am trying to get to
a’ = (a), b’ = (a+b+c)/3, c’ = (a+b+c+d+e)/5, d’ = (a+b+c+d+e+f+g)/7, e’ = (a+b+c+d+e+f+g+h+i)/9, f’ = (b+c+d+e+f+g+h+i+j)/9, ………… q’ = (m+n+o+p+q+r+s+t+u)/9, r’ = (n+o+p+q+r+s+t+u+v)/9, …………, v’ = (r+s+t+u+v+w+x+y+z)/9, w’ = (t+u+v+w+x+y+z)/7…….. y’ = (x+y+z)/3, z’ =z
. <- how I am trying to get there

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!