How can I find the number of row in which the maximum value obtained for a particular column?

3 次查看(过去 30 天)
n = 3
B = rand(n)
A = B
for j = 1:length(A(1,:))
Amax = A(1,j);
for i = 1:length(A(:,1))
if(A(i,j)> Amax)
Amax = A(i,j);
else
Amax = Amax;
end
end
Amax1(1,1)=Amax
end

采纳的回答

KSSV
KSSV 2021-1-6
Read about the function max.
A = rand(10) ; % 10*10 matrix
[val,idx] = max(A(:,3)) % maximum value for the oclumn 3
val = 0.9846
idx = 4
fprintf('The maximum value occurs in %d row\n',idx)
The maximum value occurs in 4 row
  3 个评论

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by