Filter löschen
Filter löschen

List of maximum number in the matrix

1 Ansicht (letzte 30 Tage)
Moe
Moe am 26 Mai 2014
Beantwortet: Star Strider am 26 Mai 2014
Hi everyone,
Suppose I have a matrix:
a = [3;1;4;2;3;4;1;4;3;1;2;4];
Then I want matrix b to be:
b = [3;6;8;12]
  • Matrix b is included the rwo number of all max number in the matrix a, e.g. row(3)=4; row(6)=4; row(8)=4; row(12)=4;
Can anyone please help me?

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 26 Mai 2014
a = [3;1;4;2;3;4;1;4;3;1;2;4];
idx=find(ismember(a,max(a)))

Weitere Antworten (1)

Star Strider
Star Strider am 26 Mai 2014
Use the find function:
a = [3;1;4;2;3;4;1;4;3;1;2;4];
b = find(a == max(a))
yields:
b =
3
6
8
12

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by