移動平均
移動平均を返す関数movingAverage。
function [ output_args ] = movingAverage(dataNx1,AverageWindowSize )
filterfunc=ones(1,AverageWindowSize);
output_args = filter(filterfunc,AverageWindowSize,dataNx1);
end
テストコード。yとして、sin関数の値にランダムノイズを加えておく。
x=0:0.05:2*pi;
y=sin(x)+rand(size(x))*0.1;
plot(x,y)
hold on
plot(x,movingAverage(y,5))
結果。青がy。赤が移動平均。