MATLAB: Using randperm without involving the first and last number

randperm

I'm going to use randperm, but I dont want the first and last number got involved.
Example:
randperm(9)
ans = 3 2 8 9 6 4 5 7 1
but I need it to be;
ans = 1 3 2 8 6 4 5 7 9
with no. 1 in the first place and the max (no. 9) in the last place.
Is that possible? Thanks for your assistance.

Best Answer

N = 9;
[1,1+randperm(N-2),N]