Finding the array location in the matrix
1 回表示 (過去 30 日間)
古いコメントを表示
Hi everyone,
Suppose I have a matrix:
b = [8;5;9;12]
and:
max(b) = 12 %12 is in the fourth row
I'm looking for a command line which instead of giving me the maximum value, give it to me as a row number (e.g = 4, not 12).
Can anyone help me please?
0 件のコメント
採用された回答
Geoff Hayes
2014 年 4 月 27 日
Hi Mohammad,
If the input is a vector, then you can do the following:
[val,idx] = max(b);
where val will be the maximum value of 12 and idx will be the index of 4. Type help max for more details. (It gets a little more complicated when the input is matrix.)
Geoff
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!