Filter löschen
Filter löschen

find max vector form many vectors

2 Ansichten (letzte 30 Tage)
fatemeh
fatemeh am 18 Okt. 2013
Kommentiert: Walter Roberson am 18 Okt. 2013
i have many 1*2 vectors how can i find the vector with the maximum value at the second index?

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 18 Okt. 2013
If you have n vectors with the same size, you can create one matrix nx2. It's not a good idea to create those vectors, just use a matrix nx2, it contains all your vectors.
a=[10 20]
b=[100 30]
c=[5 2]
% create a matrix M
M=[a;b;c]
c2=M(:,2) % The second column
[max_value,index]=max(c2)
  5 Kommentare
fatemeh
fatemeh am 18 Okt. 2013
how? i write this vectors for 1000 times in the M ?
Walter Roberson
Walter Roberson am 18 Okt. 2013
Did you read the FAQ link I posted?
Best solution: do not use 1000 different vectors to start with.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrix Indexing 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