random pick cell array

5 Ansichten (letzte 30 Tage)
Sahab
Sahab am 7 Mai 2011
how to randomly picking in cell array? for example,i want to pick randomly one data in x.
x=[1;8;9;10;16]

Antworten (1)

Paulo Silva
Paulo Silva am 7 Mai 2011
x=[1;8;9;10;16]; %is one array not cell array
x(randi([1 numel(x)])) %show one random element of the array

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by