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개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 18일

0 개 추천

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

fatemeh
fatemeh 2013년 10월 18일
i want it for great population like 1000 vectors...
Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 18일
Ok, you can create a 1000x2 matrix
fatemeh
fatemeh 2013년 10월 18일
how? i write this vectors for 1000 times in the M ?
Walter Roberson
Walter Roberson 2013년 10월 18일
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일

댓글:

2013년 10월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by