Clear Filters
Clear Filters

How to use loop function to find the 1st to Nth elements' average, and then 2nd to Nth element's average? Thanks

1 view (last 30 days)
Hi guys thanks for helping me. Suppose i have 700 data in a column, and i want to find out the first 120 elements' average. Then starting from this point, i want to find out the average of the sum of from 121st to the 700th, then from 122nd to 700th and so on. I know i have to use iteration to solve this, but i fail to set up a good algorithm and required syntax.
I am beginner of Matlab, please help me, thank you !!

Accepted Answer

dpb
dpb on 30 Sep 2016
Navg=120; % number for moving average
krnl=ones(N,1)/N; % convolution kernel over N elements
xfilt=conv(x, krnl, 'valid') % filtered mean result over valid elements

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!