maximum position of element in a matrix
7 ビュー (過去 30 日間)
古いコメントを表示
Hi I have a 1000x1000 matrix. I want to find the location and the value of the highest value in the matrix?
0 件のコメント
採用された回答
Richard Brown
2012 年 4 月 11 日
Pretty straightforward - the only complicating factor is that max only works down one dimension at a time, so you either have to call it twice or turn the matrix temporarily into a vector. Probably easiest is this:
M = rand(1000);
[maxVal, idx] = max(M(:));
idx is a linear index. If you want the row/column index then
[i, j] = ind2sub(size(M), idx);
0 件のコメント
その他の回答 (1 件)
参考
カテゴリ
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!