Return matrix of maximum values
3 次查看(过去 30 天)
显示 更早的评论
I have a matrix of the form:
a =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
column 1 & 2 represent x,y positions while col 3-5 represent intensity. I obtained the maximum and index of the intensity for each position from [M,I] =max(a(:,3:5),[],1). I am struggling with how to obtain the x,y positions corresponding to each maximum intensity. Any help would be appreciated. Thanks.
采纳的回答
madhan ravi
2019-2-20
x(I)
y(I)
更多回答(1 个)
Jos (10584)
2019-2-20
maxxy = zeros(3, 2) ; % pre-allocation
for k = 1:3
[~, r] = max(M(:, k+2)) ; % row of maximum value in column k
maxxy(k, :) = M(r, [1 2]) ;
end
另请参阅
类别
在 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!