フィルターのクリア

Finding column and row number of a element in array

4 ビュー (過去 30 日間)
Sang Heon Lee
Sang Heon Lee 2017 年 9 月 25 日
編集済み: Stephen23 2017 年 9 月 25 日
How can I get the number of column and row which certain element of array in located?
For example, for a array or matrix of [1,2,3;4,5,6;7,8,9], how can I obtain the value of row = 3 and column = 3 for finding the maximum value? (which is 9 in this case)

回答 (1 件)

Stephen23
Stephen23 2017 年 9 月 25 日
編集済み: Stephen23 2017 年 9 月 25 日
>> A = [1,2,3;4,5,6;7,8,9]
A =
1 2 3
4 5 6
7 8 9
>> [val,idx] = max(A(:));
>> [row,col] = ind2sub(size(A),idx)
row =
3
col =
3
>> val
val =
9

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by