Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
sliding window min/max

Subject: sliding window min/max

From: radar

Date: 17 Nov, 2010 16:38:20

Message: 1 of 5

Is there a built-in function that would return the max of a vector V of length N sliding over it in M-sized windows? The first M-1 values of V are NaN.

Subject: sliding window min/max

From: Bruno Luong

Date: 17 Nov, 2010 17:01:06

Message: 2 of 5

radar <able@tds.net> wrote in message <1533648139.21444.1290011930159.JavaMail.root@gallium.mathforum.org>...
> Is there a built-in function that would return the max of a vector V of length N sliding over it in M-sized windows? The first M-1 values of V are NaN.

imerode() and imdilate() if you have license for image processing toolbox.

Bruno

Subject: sliding window min/max

From: someone

Date: 17 Nov, 2010 17:07:04

Message: 3 of 5

radar <able@tds.net> wrote in message <1533648139.21444.1290011930159.JavaMail.root@gallium.mathforum.org>...
> Is there a built-in function that would return the max of a vector V of length N sliding over it in M-sized windows? The first M-1 values of V are NaN.

% If you just want to exclude the NaNs,
% You could do something like:

v = [nan nan 1 2 3];
max(v(~isnan(v)))

ans =

     3

Subject: sliding window min/max

From: radar

Date: 17 Nov, 2010 17:22:09

Message: 4 of 5

Thank you. I really enjoy using logical indexing. It's so clean and succinct.
 
And you can also use nanmax() if you have the Statistics Toolbox.

Subject: sliding window min/max

From: radar

Date: 17 Nov, 2010 17:24:33

Message: 5 of 5

Thank you. I do have that license.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us