Finding the corresponding number in a matrix
6 ビュー (過去 30 日間)
古いコメントを表示
I need to find a number in one column that corresponds with a different column. For example: [1 2 4 6 10 9; 3 5 7 2 8 6], I want the max in column 1, which is ten, I also want to find 8 in the second column.
0 件のコメント
回答 (2 件)
Image Analyst
2022 年 9 月 11 日
m = [1 2 4 6 10 9; 3 5 7 2 8 6]
% Find maxes in each of the 2 rows (consisting of 6 columns):
maxesOfRows = max(m, [], 2)
% Find maxes in each of the 6 columns (consisting of 2 rows):
maxesOfColumns = max(m, [], 1)
2 件のコメント
Walter Roberson
2022 年 9 月 11 日
m = [1 2 4 6 10 9; 3 5 7 2 8 6]
[~, idx] = max(m(1,:));
m(2,idx)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!