필터 지우기
필터 지우기

Moving window of 100 points with 20 points overlap.

조회 수: 1 (최근 30일)
davit petraasya
davit petraasya 2016년 2월 15일
댓글: Image Analyst 2016년 2월 16일
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 ...
[NUMERIC,TXT,RAW]=XLSREAD('sihex.xlsx');
A= -0.59;
B = 43.45;
C=0.09;
x=NUMERIC(:,2);
y=NUMERIC(:,1);
Mag=NUMERIC(:,3);
for iii=1:length(TXT);
date_str(iii,:)=TXT(iii,1);
end
date_num=datenum(date_str,'dd/mm/yyyy');
condition11=(Mag >= 0.8 & x > A-C & x < A+C & y > B-C & y < B+C);
plot(date_num(condition11),Mag(condition11),'.b');
datetick('x','yyyy','keeplimits'))

채택된 답변

dpb
dpb 2016년 2월 15일
Nfilt=20;
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
  댓글 수: 3
dpb
dpb 2016년 2월 15일
I've no klew what the "100 events" means, the above is a moving average of nPoints.
Oh, rereading I missed part of the request...no, the above doesn't do the "jump", it's a step increment of unity. As IA says, use either blockproc or conv instead.
davit petraasya
davit petraasya 2016년 2월 15일
Sorry dpb for my a little bit confusion text. Actually events means points. 100 events=100 points. Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2016년 2월 15일
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.
  댓글 수: 2
davit petraasya
davit petraasya 2016년 2월 15일
Thanks for the comment Image Analyst. I will try to use blockproc function.
Image Analyst
Image Analyst 2016년 2월 16일
I've attached two demos where I use the function in a wide variety of ways. Adapt as needed. Good luck.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by