I need to know if there is a any function in matlab to choose random numbers from a given list. The list is given by the user. Suppose the list is (4,9,10,18,2) each time I want one value to be taken for calculation what function do I use?

 Akzeptierte Antwort

yourlist(randi(numel(yourlist)))

3 Kommentare

Just index using randi() pr randperm() :
yourlist(randperm(numel(yourlist),1))
Sir
out of a list if I want to take each element in an order then what function do I use?
Can you illustrate with an example?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by