Suppose I have a 2D array like this :
Array = [1 2 3; 5 1 6; 4 3 2]
I want to find the minimum value between each row, and save the column index of that result. I want my answer's like this :
ans = [1; 1; 2]
and the index :
column_index = [1; 2; 3]
Can somebody please help me? Thank you.
You are looking to find the minimum values along the second dimension. Use min
-
[minval,column_index] = min(Array,[],2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.