Index vector:
The index vector is then used as the indices for original vector. To get grades vector in ascending order, the indices used would be grades (2), grades (5), and so forth. By using the index vector to complete this, grades (grade_index(1)) would be the minimum grade, 70, and grades (grade_index(2)) would be the second lowest grade. In common, grades (grade_index(i)) would be the ith lowest grade. To generate these in MATLAB:
>> grades = [85 70 100 95 80 91];
>> grade_index = [2 5 1 6 4 3];
>> grades(grade_index)
ans =
70 80 85 91 95 100