random pick cell array

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 日

0 投票

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

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2011 年 5 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by