Is there a Scilab function to compute a running average over a specified number of column entries within an array:
|Values in array||3 cell running average|
Thanks in advance!
Not as such. However, a routine for calculating a simple moving average can be easily written. Here is one. Please test it extensively before relying on it.
Please feel free to improve this code and report fail cases.
//Function to compute simple moving average. //vec is a simple row or column vector //windw is the number of data points over which the average has to be computed //avg is a column vector consisting of the computed moving averages //Example: //-->sma([6,3,7,4,10,2,0],3) // ans = // // 5.3333333 // 4.6666667 // 7. // 5.3333333 // 4. //Author: Rupak Rokade //FOSSEE, IIT Bombay function avg=sma(vec, windw) avg= for i=1:length(vec)-windw+1 av=sum(vec(i:i+(windw-1)))/windw avg=[avg;av] end endfunction