How would one find the minimum value in each row, and also the index of the minimum value?
octave:1> a = [1 2 3; 9 8 7; 5 4 6]
a =
1 2 3
9 8 7
5 4 6
How would one find the minimum value in each row, and also the index of the minimum value?
octave:1> a = [1 2 3; 9 8 7; 5 4 6]
a =
1 2 3
9 8 7
5 4 6
This is hard to find in the documentation. https://www.gnu.org/software/octave/doc/v4.0.3/Utility-Functions.html
octave:2> [minval, idx] = min(a, [], 2)
minval =
1
7
4
idx =
1
3
2
If A is your matrix, do:
[colMin, row] = min(A);
[rowMin, col] = min(A');
colMin will be the minimum values in each row, and col the column indexes. rowMin will be the minimum values in each column, and row the row indexes.
To find the index of the smallest element:
[colMin, colIndex] = min(min(A));
[minValue, rowIndex] = min(A(:,colIndex))
Suppose X is a matrix
row, col = Row and Column index of minimum value
[min_value, column_index] = min(X(:))
[row, col] = ind2sub(size(X),column_index)
Given a matrix A of size m x n, you need to find the row number for the smallest value in the x column.
e.g A is 64x3 sized;
search_column = 3;
[val,row] = min(results(:,search_column),[],1);
#row has the row number for the smallest value in the 3rd column.
Get the values for the first and second columns for the smallest row value
column1_value = A(row,1);
column2_value = A(row,2);