From: Magnus Lilledahl on
I want to find the indicies of the maximum value in an image/matrix c and do it like this:

[d,i] = max(c);
[e,j] = max(d);
col = i(j);
row = j;

This seems like a lot of code for a simple task. How could this be achieved with more condensed (prettier) code?

Magnus
From: Bruno Luong on
"Magnus Lilledahl" <mlilledahl(a)gmail.com> wrote in message <hrn4t6$msd$1(a)fred.mathworks.com>...
> I want to find the indicies of the maximum value in an image/matrix c and do it like this:
>
> [d,i] = max(c);
> [e,j] = max(d);
> col = i(j);
> row = j;
>

There is a similar thread posted recently:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/280760

Bruno
From: us on
"Magnus Lilledahl" <mlilledahl(a)gmail.com> wrote in message <hrn4t6$msd$1(a)fred.mathworks.com>...
> I want to find the indicies of the maximum value in an image/matrix c and do it like this:
>
> [d,i] = max(c);
> [e,j] = max(d);
> col = i(j);
> row = j;
>
> This seems like a lot of code for a simple task. How could this be achieved with more condensed (prettier) code?
>
> Magnus

a hint:

help max; % <- then, look at the second output arg...

us
From: ImageAnalyst on
Not sure what d is, but if you just want to "find the indicies of the
maximum value in an image/matrix c" like you said, then how about
this:
[rows columns] = find(c == max(max(c)));