Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   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
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.