Created
March 30, 2018 00:00
-
-
Save yusufcakal/0aa687a0ef0ab6ea10890d1ddcd03daf to your computer and use it in GitHub Desktop.
Daily Moving Avarage in Matlab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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