MATLAB: How to avoid the rows not to get repeated again

eliminating duplicate rows

If the run the following code it works.
M=rand(14);
for N=2:5
c=randperm(length(M),N)
B=M(c,:) % output matrix
end
but the rows are getting repeated again and again .How can i avoid the duplicate rows not to get repeat it again .

Best Answer

M=rand(14);a=1:14;
for N=2:5
c=randsample(a,N)
B=M(c,:);
[~,idx]=find(ismember(a,c));
if N==5
else
a(idx)=[];
end
end