Asked by PK
on 11 Sep 2012

Can some one help in picking a number from a matrix for example i have matrix of the form A=[1 2 3 4 5; 6 6 7 5 8 ; 12 4 5 6 9] and i require to pick only one element randomly from the matrix but should not be the same element every time.

*No products are associated with this question.*

Answer by Andrei Bobrov
on 11 Sep 2012

Edited by Andrei Bobrov
on 11 Sep 2012

Accepted answer

try this is code

A=[1 2 3 4 5; 6 6 7 5 8 ; 12 4 5 6 9]; a = unique(A); b = a(histc(A(:),a) < 2); idx = randperm(numel(b)); out = b(idx(1));

Opportunities for recent engineering grads.

## 0 Comments