Skip to content

Instantly share code, notes, and snippets.

@yusufcakal
Created March 30, 2018 00:00
Show Gist options
  • Save yusufcakal/0aa687a0ef0ab6ea10890d1ddcd03daf to your computer and use it in GitHub Desktop.
Save yusufcakal/0aa687a0ef0ab6ea10890d1ddcd03daf to your computer and use it in GitHub Desktop.
Daily Moving Avarage in Matlab
v = [4 3 0 1 7]
daily = 3;
h = dailyMovingAvarage(daily, v);
h
function h = dailyMovingAvarage(daily, v)
size = length(v);
h = zeros(1, size);
for i=1:size-daily+1
sum = 0;
for j=i:i+daily-1
sum = sum + v(j);
end
h(i + (daily-1)) = sum / daily;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment