Moving window of 100 points with 20 points overlap.

11 views (last 30 days)
davit petraasya
davit petraasya on 15 Feb 2016
Commented: Image Analyst on 16 Feb 2016
Hi everybody
I have around 500 points. My x axis-times, y-magnitudes. I need to do plot moving window of 100 points averages with 20 point overlap over time. How I may do the plot? I attached something sample plot also. (Please see my code and excel file, I need to continue my this code ...
A= -0.59;
B = 43.45;
for iii=1:length(TXT);
condition11=(Mag >= 0.8 & x > A-C & x < A+C & y > B-C & y < B+C);

Accepted Answer

dpb on 15 Feb 2016
b=ones(1,Nfilt)/Nfilt; % weights
magFiltered=[nan filter(b,1,mag)]; % weight average (includes end effects)
magFiltered(2:nFilt-1)=nan; % replace end effects w/ NaN keeping time location
davit petraasya
davit petraasya on 15 Feb 2016
Sorry dpb for my a little bit confusion text. Actually events means points. 100 events=100 points. Thanks.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 15 Feb 2016
An alternate way is to use blockproc(), if you have the Image Processing Toolbox. It gives you control over the window size and the "jump" length.
Or, you could use conv() (which moves over one element at a time) and then just subsample every 20th element from the result.
Image Analyst
Image Analyst on 16 Feb 2016
I've attached two demos where I use the function in a wide variety of ways. Adapt as needed. Good luck.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!