I wrote a script to compute simple moving average of a vector using for-loop:
X=rand(1000,1);
Y=nan(size(A));
for i=100:length(A);
Y(i)=mean(X(i-99:i));
end
Could I use any vectorization method to avoid the loop? Thanks.
I wrote a script to compute simple moving average of a vector using for-loop:
X=rand(1000,1);
Y=nan(size(A));
for i=100:length(A);
Y(i)=mean(X(i-99:i));
end
Could I use any vectorization method to avoid the loop? Thanks.