moving sum using movsum()
이전 댓글 표시
I am new to matlab and this is a code for computing moving sum from 3 consecutive numbers in matlab from Mathworks documentation. I am unable to understand what they mean by discarding endpoint calculations in the explanation(underlined ). I do not understand the significance of endpoints and discard keyword in the given documentation.If someone can explain this it would be very helpful .
Compute the three-point centered moving sum of a row vector, but discard any calculation that uses fewer than three points from the output. In other words, return only the sums computed from a full three-element window, discarding endpoint calculations.
A = [4 8 6 -1 -2 -3 -1 3 4 5];
M = movsum(A,3,'Endpoints','discard')
M = 1×8
18 13 3 -6 -6 -1 6 12
채택된 답변
추가 답변 (1개)
Image Analyst
2020년 5월 24일
1 개 추천
If the window cannot overlap the ends without the window sticking out past the edge of the vector, then it essentially stops there, it doesn't move closer to the ends so any values it might compute there, say be shrinking the window or padding with zeros, are discarded. Thus, the resulting vector will be shorter by the width of window (half a window width on each end are discarded).
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!