Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Averaging of 8 successive values in array
Replies: 1   Last Post: Sep 24, 2013 11:24 AM

 Messages: [ Previous | Next ]
 Surendhra Goli Posts: 3 Registered: 7/8/13
Averaging of 8 successive values in array
Posted: Sep 24, 2013 10:57 AM

I have my Value array which is for unknown number of values

Value =
78 74 77 75 75 78 75 77 76 81 76 92 98

I want to calculate the moving average of first 8 values (i.e (78 74 77 75 75 78 75 77)/8 =76.125) and need to store in Average 1st value and after i need to calculate next 8 values (i.e (74 77 75 75 78 75 77 76)/8=75.875 )and need to store in Average 2nd value

for this i wrote a program but its result showing only the first value of Value is average for entire series ....

avg=[];
i=1;
for i=1:length(Value);
Average=0;
j=1;
if j<=i+7;
Average=Average+Value(j);
j=j+1;
end
% if Average==0;
% Average=Average/8;
% end
avg(i)=Average
i=i+1;
end

But I am not sure whether it?s a correct command to be used or not. I appreciate any comment that you give on first how to calculate.

thanks & regards

surendra

Date Subject Author
9/24/13 Surendhra Goli
9/24/13 Curious