Azzera filtri
Azzera filtri

how to find matrix indices

1 visualizzazione (ultimi 30 giorni)
sowndharya
sowndharya il 8 Mar 2013
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?

Risposta accettata

Wayne King
Wayne King il 8 Mar 2013
Modificato: Wayne King il 8 Mar 2013
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 Commento
sowndharya
sowndharya il 14 Mar 2013
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?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Operating on Diagonal Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by