MATLAB: How to find the middle 25% of an array

array

Hello,
I have an array X with N elements. Is there a way to obtain a new array Y which comprises the middle 25% of array X?
Thanks for the help.

Best Answer

Try this
X = length(yourVector)
index1 = round(vecLength * (0.5 - 0.25/2))
index2 = round(vecLength * (0.5 + 0.25/2))
Y = X(index1 : index2)