How to extract all the elements in a vector whose index is 1?
2 visualizzazioni (ultimi 30 giorni)
Given a vector R:
R=[0.7 9 8 34 2]'; ranks=[1 2 2 2 3];
Where the first element in ranks crossponds to the rank of the first element in R and the second element in ranks crossponds to the second element in R and so on.
I need to extract all the elements whose ranks are 2 and put them in a vector but I need a general way because the sizes of the vectors R and ranks will vary
I appreciate your help