how to find matrix indices

1 次查看(过去 30 天)
k=1:2; t=1:2; x(k,t)=[1.2 1.3;1.8 1.5] max(x) I have entered input x and found max(x).For what value of k and t , x is maximum ?How to find this using matlab code?

采纳的回答

Wayne King
Wayne King 2013-3-8
编辑:Wayne King 2013-3-8
Do you want the single biggest element in the matrix? If so then, just max() will not give you that. You'll get a row vector of the largest elements in each column.
X = [1.2 1.3;1.8 1.5];
[val,idx] = max(X(:));
[I,J] = ind2sub(size(X),idx);
X(I,J)
is the largest element.
  1 个评论
sowndharya
sowndharya 2013-3-14
I want max value in every column so i have used max command .That was helpful.but i want to find the next maximum value in all the columns.This process have to be repeated till finding the least value in that column.i mean in descending order.for ex x=[1 2 3;4 5 6;7 8 9] max(x) will give (1 4 7) [x,y]=max(x) y gives (1 1 1) (indices)
next i have to find next max (2,5,8) the indices i should get (2 2 2) what command i should use?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by