How i will choose a random element of a matrix
Show older comments
I have a matrix A,and i want to choose randomly an element from the matrix.How i will do that?
Accepted Answer
More Answers (1)
Guillaume
on 24 Mar 2015
It may be (insignificantly) faster to use linear indexing:
A(randi(numel(A)));
It's more succinct anyway, and works whatever the number of dimensions of the array.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!