MATLAB: Pick a random entry from a vector

random entryvector

Hello, is there a matlab function that picks a random entry from a vector? I solved the problem with
i=randperm(length(vector),1),
entry=vector(i).
But i wondered if there is a more elegant solution. Thank you

Best Answer

entry = vector(randi(length(vector)));