Implement sliding window for vector

1 view (last 30 days)
Biomed
Biomed on 12 May 2016
I have an ecg data vector X(n), with size 3,000 for which I want to get the Gradient G using the following formula:
G(n)=Xmax(w)-Xmin(w),
where: w is is a rectangular sliding window of size 11, centered at nth element, Xmax is the maximum value of X(n) within the window and Xmin is the minimum value of X(n) within the window.
How can I do that?
I know I can use a loop, but how to get window of 11 elements for the first and last 5 elements in the vector X(n)? for example: for X(6), I use X(1:5) as half of the window and the other half zeros? Help please.

Answers (0)

Categories

Find more on Entering Commands 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!