Hi, I am new to matlab. I was solving a problem where I have to find moving average of a sample single .The output should be centered. I wrote the following code
t=linspace(-pi,pi,100);rng defaultx=sin(t) +0.25*rand(size(t));window_s=5;output_l=length(t) -window_s+1;y=zeros(1,output_l);for k=1:output_l y(k)=(x(k) +x(k+1) + x(k+2)+x(k+3)+x(k+4))/5;endplot(t,x)hold onplot(t(1:output_l),y)legend('Input Data', 'Filtered Data')
I dont know what is the meaning of centered moving average? Can someone tell me how can make the out put centered?
Best Answer