minimum value of a matrix

John W. Eaton jwe at bevo.che.wisc.edu
Mon Dec 1 09:41:48 CST 2008


On  1-Dec-2008, Luca Penasa wrote:

| How can i find the minimum value of a matrix? i mean find the row and
| column index of the cell that contains the minimum value...
| I see that min() give the minimum of every column...

Something like

  x = rand (2, 3, 4);
  [val, ind] = min (x(:));
  subs = cell (ndims (x), 1);
  [subs{:}] = ind2sub (size (x), ind);

should do it.

jwe


More information about the Help-octave mailing list