You can use randi
index = randi(length(A(:)),1,1);
A(index)
for a 1-D vector, you can just do length(A), but length(A(:)) will work with a matrix as well.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!