[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Finding local minima in a multidimensional array
From: |
Juan Pablo Carbajal |
Subject: |
Re: Finding local minima in a multidimensional array |
Date: |
Wed, 20 Nov 2019 15:03:50 +0100 |
Hi Brett,
Did you solve your problem?
It seems the definition of the minima you are looking for is
problematic, in 1D it reads
# assume M exist with length N
i = 2:(N - 1);
ismin = (M(i) < M(i + 1)) & (M(i) < M(i - 1))
# these are the location of minima
loc = find (ismin) + 1
But check this
M = [1 2 3 0 0 5 6];
gives you no minima. Is that alright?
On Sat, Nov 9, 2019 at 7:01 PM Brett Green <address@hidden> wrote:
>
> I would like to find all local minima in an array. For a 2D array M, I would
> want to find (i,j) such that:
> M(i,j)<M(i,j+1)
> M(i,j)<M(i,j-1)
> M(i,j)<M(i+1,j)
> M(i,j)<M(i -1,j).
> I would like to do this in higher dimensions as well. This seems similar to
> the sort of thing that could be done with the "find" function. I've seen find
> used for elementwise operations, but I don't know whether it can be used for
> comparisons that require accessing two elements of the array which is passed
> in. Is that possible?
>
> While it's easy enough to write loops to do this for 1 or 2 dimensions, it
> would be nice to have a more general method.
>
> - Brett Green
>