I have already a program for moving average that I want to implement. Now this program gives output one by one if I take a for loop. Now what I want is to store each result into an empty array. It will be Like :
for i=1:size(A,2) % for each row of matrix A
....my moving avg. program
..... output of moving average for each i
end
now I want to store these individual i values in a out put file or an empty matrix. That was my question? In what way i can do it? Sorry I cudn't frame my question properly before.
"Roger Stafford" wrote in message <jabk79$d58$1@newscl01ah.mathworks.com>...
> "Pg " <poulomizca@gmail.com> wrote in message <jabg3i$sjk$1@newscl01ah.mathworks.com>...
> > ..... I want to compute moving average of each row of matrix A and store the output to a new matrix B of size (420mx151), where m is the sliding window size. .....
>          
> Try this:
>
> B = [zero(size(A,1),1),cumsum(A,2)];
> B = (B(:,m+1:end)B(:,1:endm))/m;
>
> Note 1: On a 420 by 151 matrix, it is the rows that are of length 151, so it is these rows whose length will be reduced to 151(m1) length giving a 420 by 152m size to B.
>
> Note 2: The 'cumsum' function should not be used with excessively large numbers of summands since this can produce significantly larger amounts of accumulated round off error than would occur if each moving average sum were calculated separately.
>
> Roger Stafford
