You can use randperm.
From the description:
p = randperm(n,k) returns a row vector containing k unique integers randomly selected from 1 to n inclusive.
So it randperm(6,3)
could be a vector
[4 2 5]
Update
Two arguments to the randperm version only appeared in R2011b, so if you are using an earlier version of MATLAB, you will see this error. In this case, use:
A = randperm(n);
A = A(1:m);