Q:

what does this do in matlab. [M , p] = max(a3 , [] , 2);

what does the left side of the following command do in matlab. 
[M , p] = max(a3 , [] , 2);
a3 is a matrix.

A:

It searches for the max value in the array a3 along the second dimension.
The variable M will have the max value and the variable p will have the index of the value (Column Index).
For instance:
>> mA = reshape(randperm(9), [3, 3])

mA =

     7     5     4
     2     6     1
     8     9     3

>> [vA, vB] = max(mA, [], 2)

vA =

     7
     6
     9

vB =

     1
     2
     2

So the variable vAhas the maximum value along row and vB has the column index.
For the first row, the max value is 7 on column 1.
For the first row, the max value is 6 on column 2.
For the first row, the max value is 9 on column 2.  

