random pick cell array

3 次查看(过去 30 天)
Sahab
Sahab 2011-5-7
how to randomly picking in cell array? for example,i want to pick randomly one data in x.
x=[1;8;9;10;16]

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by