From: LFG Tech on
Hello,

I want to find the maximum value and the coordinate of that value of amatrix.

eg x = [1 2 3 4;
2 3 4 5;
4 5 6 7;
9 6 5 4];

using max(max(x)). I get 9. I want the coordinates of '9'(in this case 4,1.

how can I achieve that?

Regards,
LFG.
From: James Tursa on
"LFG Tech " <vinodkaruvat(a)gmail.com> wrote in message <hnkpen$he7$1(a)fred.mathworks.com>...
> Hello,
>
> I want to find the maximum value and the coordinate of that value of amatrix.
>
> eg x = [1 2 3 4;
> 2 3 4 5;
> 4 5 6 7;
> 9 6 5 4];
>
> using max(max(x)). I get 9. I want the coordinates of '9'(in this case 4,1.
>
> how can I achieve that?
>
> Regards,
> LFG.

[C X] = max(x(:));
[I J] = ind2sub(size(x),X);

James Tursa