フィルターのクリア

Finding a position of minimum value element in a matrix

1 回表示 (過去 30 日間)
NIRBAN CHAKRABORTY
NIRBAN CHAKRABORTY 2022 年 1 月 7 日
コメント済み: Matt J 2022 年 1 月 7 日
I have matrix of 10*73 with random variable
Now i want to find out the minimum value in 13 to 20th column in each row
if i write the program like this is it work
for i=1:10
[r1,c1]=find(a(i,1:73)==min(a(i,13:20)))

回答 (1 件)

KSSV
KSSV 2022 年 1 月 7 日
編集済み: KSSV 2022 年 1 月 7 日
A = rand(10,73) ;
[iwant,idx] = min(A(:,13:20),[],2) % idx gives column position
iwant = 10×1
0.1923 0.1928 0.1840 0.0789 0.2020 0.0124 0.5000 0.0500 0.1418 0.0890
  1 件のコメント
Matt J
Matt J 2022 年 1 月 7 日
If the column position needs to be with respect to the original dimensions of A, then you also need,
idx=idx+12;

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品


リリース

R11.1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by