# minindc#

## Purpose#

Returns a column vector containing the index (i.e., row number) of the smallest element in each column of a matrix.

## Format#

y = minindc(x)#
Parameters:

x (NxK matrix) – data

Returns:

y (Kx1 matrix) – contains the index of the smallest element in each column of x.

## Examples#

```// Create random matrix
x = round(rndn(5, 4)*5);

// Find minimum of each column
y = minc(x);

// Find indices of minimum of each column
z = minindc(x);
```

If x is equal to:

```     -5      4     -4      0
-2      3      4      3
x = -11      5      5      5
1      2      7      4
-2      4     -1     -5
```

then y and z are equal to:

```    -11          3
y =   2      z = 4
-4          1
-5          5
```

## Remarks#

If x is complex, `minindc()` uses the complex modulus (`abs(x)`) to determine the smallest elements.

To find the index of the smallest element in each row, transpose the matrix before applying `minindc()`.

To find the index of the smallest element in a matrix x, use:

```colInd = minindc(minc(x));
rowInd = minindc(x[.,colInd]);
```

If there are two or more “smallest” elements in a column (i.e., two or more elements equal to each other and less than all other elements), then `minindc()` returns the index of the first one found, which will be the smallest index.