how to randomly select an element in a matrix

1 vue (au cours des 30 derniers jours)
cgo
cgo le 19 Oct 2015
Hi,
I have a matrix for example A = [1,2,3,4,5,6]; I would like to randomly select an element in A.
How do I do that?

Réponse acceptée

Walter Roberson
Walter Roberson le 19 Oct 2015
A(randi(numel(A)))
  1 commentaire
PANTHAGADA ANIL KUMAR
PANTHAGADA ANIL KUMAR le 2 Avr 2020
how do i know which element it has randomly selected ???

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by