Assuming you have arrays of X and Y and you want to find the five smallest values ββof Y:
[m mi] = sort(Y); lowest5index = mi(1:5); lowest5Y = Y(lowest5index); lowest5X = X(lowest5index); meanYlowest5 = mean(lowest5Y); meanXlowest5 = mean(lowest5X);
Explanation:
The sort command with two output parameters returns both the sorted array (in m ) and the indices in the original array ( mi ). The first five mi(1:5) indices mi(1:5) correspond to the five lowest values. Taking mean these values ββfor X and Y will do what we want. If I do not understand your expression about the problem, clarify your question and I will take another picture.
source share