[英]Find column index of minimum value from 2D arrays
假設我有一個像這樣的2D數組:
Array = [1 2 3; 5 1 6; 4 3 2]
我想找到每一行之間的最小值,並保存該結果的列索引。 我想要我的答案是這樣的:
ans = [1; 1; 2]
和索引:
column_index = [1; 2; 3]
有人能幫幫我嗎? 謝謝。
您正在尋找沿第二維的最小值。 使用min
[minval,column_index] = min(Array,[],2)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.