MATLAB: How i will choose a random element of a matrix

matrixrandom

I have a matrix A,and i want to choose randomly an element from the matrix.How i will do that?

Best Answer

One way
A = rand(3,4)
A( randi([1,size(A,1)],1), randi([1,size(A,2)],1) )
Related Question