MATLAB: Vector array from matrix

arraymatrixmatrix arraymatrix_arrayrow_vectorvectorvector matrixvectorization

Can anyone suggest me the general code for finding the difference between maximum and minimum value in a higher order matrix to get each row answers in vector form.

Best Answer

If A = [1 0 5; 6 -9 -5; 1 2 5; 0 0.9 -2]
then min(A,[],2) gives a column vector containing minimum value of each row. Similarly for max(A,[],2).
>> min(A,[],2)
ans =
0
-9
1
-2
(Here third argument is to specify dimension along which to find min/max)