MATLAB: Cut the last n of matrix row

matrix manipulation

e.g i have matrix a :
1
2
3
4
5
6
7
i want to cut the last 2 row of matrix A ? and become
1
2
3
4
5

Best Answer

a = (1:7)'; n = 2;
A = a(1:end - n);
or
a(end - [n-1, 0]) = [];