How to generate unique random samples for the following scenario?

3 ビュー (過去 30 日間)
Manas Gupte
Manas Gupte 2017 年 10 月 9 日
コメント済み: Manas Gupte 2017 年 10 月 9 日
I have rectangular formation of 208 bolts( 8 along the height and 28 along the length). I want to generate a random sample set of 10000 points which would give me different combinations of bolt failures. There is no restriction on the number of bolts that can fail.

採用された回答

Image Analyst
Image Analyst 2017 年 10 月 9 日
編集済み: Image Analyst 2017 年 10 月 9 日
This will do it:
for k = 1 : 1000
% Get the number of failures for this row.
numFailures = randi(208);
% Get the failed indexes.
failedIndexes{k} = randperm(208, numFailures);
end
% Print to command window.
celldisp(failedIndexes);
Because it's a different number of failures each time, I used a cell array. You could use a regular array if you want - just make it big enough and set non-failures to nan or 0 or something.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by