MATLAB: Keeping rows of a matrix between two indicies.

indexingmatrix

Hi. I want to remove all rows from a matrix below idx1 and above idx2. that is I only want to keep rows that are between idx1 and idx2.
I have used this to do the 1st part:
C2(1:idx1,:) = []; %Trim the first rows upto idx1
But can't quite work out how to include removing above idx2 as the indexes will have changed now the above removal has occurred?
Thanks

Best Answer

One approach:
A=randi([1 5],15,5);%demo data
idx2=3;idx1=8;
A=A(idx2:idx1,:)