Borrar filtros
Borrar filtros

pick a random entry from a vector

5 visualizaciones (últimos 30 días)
Lou
Lou el 28 de Ag. de 2015
Respondida: the cyclist el 28 de Ag. de 2015
Hello, is there a matlab function that picks a random entry from a vector? I solved the problem with
i=randperm(length(vector),1),
entry=vector(i).
But i wondered if there is a more elegant solution. Thank you

Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de Ag. de 2015
entry = vector(randi(length(vector)));

Más respuestas (1)

the cyclist
the cyclist el 28 de Ag. de 2015
If you have the Statistics and Machine Learning Toolbox, you can use the datasample function.

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by