find max vector form many vectors

i have many 1*2 vectors how can i find the vector with the maximum value at the second index?

回答(1 个)

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 个评论

i want it for great population like 1000 vectors...
Ok, you can create a 1000x2 matrix
how? i write this vectors for 1000 times in the M ?
Did you read the FAQ link I posted?
Best solution: do not use 1000 different vectors to start with.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Matrix Indexing 的更多信息

标签

提问:

2013-10-18

Community Treasure Hunt

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

Start Hunting!

Translated by