How to get Index of matrix after Max and Min

for example
a=[1 2 3; 4 5 6];
b=max(min(a);
what i want,
for min(a)=[1 4]' , index(1,1 2,1)
b=max(min(a))= 4 , index as 2,1
how can i do this? i require the final index as said above. what is the code for it.

Antworten (1)

Mischa Kim
Mischa Kim am 15 Apr. 2014
Bearbeitet: Mischa Kim am 15 Apr. 2014

0 Stimmen

Praveen, use something like
ind = arrayfun(@(ii) find(a(ii,:)==min(a(ii,:),[],2)),1:size(a,1));
to get the column indices of the row minima, and
[r c] = find(a == max(min(a,[],2)));

3 Kommentare

The first expression
[r c] = find(min(a,[],2));
is independent of the content of a. r & c will depend only on the size(a,1). r will be [1:size(a,1)]' while c will be ones(size(a,1),1) for any a!
max() and min() return the index of the located minimax in the 2nd argument.
Mischa Kim
Mischa Kim am 15 Apr. 2014
Thanks for the catch.
Praveen
Praveen am 20 Apr. 2014
thank you for your response,
i used [k,v]=max(min(b));
where k gives the value and v gives the index. for my problem this was enough as
min(a)=[1 2 3] [k,v]=max(min(b)); output : k=3 v=3. this one solved my problem. thank you for your other choices , i will try them in future.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 15 Apr. 2014

Kommentiert:

am 20 Apr. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by