MATLAB: Functions to exclude repetitions

no repeat;randomwhile loop

hello everyone, I want to know if there is a function that allows me, through a random variable, to run my code with all the elements of a matrix 1xn without repetition. here's an example of what i want to do:
Caos = [1:10]; %is my matrix
a = min(Caos); %minimum value of "Caos"
b = max(Caos); %maximum value of "Caos"
c = length(Caos);
d = 0; %counter
R = randi([a b],1); %random variable that's I don't want to repeat
while d<c
%execute my code

Best Answer

R2 = unique( R, 'stable' );
'stable' to avoid to sort R2