RANDWORD

バージョン 1.1.0.0 (1.87 KB) 作成者: Thomas
Generate a random word from an alphabet
ダウンロード: 1.2K
更新 2010/2/5

ライセンスの表示

RANDWORD generates a random word from an alphabet. The words are selected from the lexicographically ordered list of all words of the given length using a random index generated with 'rand'.

WORD = RANDWORD(alpha, wordSize) returns a random word in
the alphabet 'alpha', with the number of symbols 'wordSize'.
The result WORD has size 1 x wordSize.

WORD = RANDWORD(alpha, wordSize, numWords) returns
'numWords' random words in the alphabet 'alpha', with the
number of symbols 'wordSize'. The result WORD has size
numWords x wordSize.

Example:
Generate 4 words of length 5 from the alphabet 'A', 'B', ..., 'Z'
word = randword('A':'Z', 5, 4)
word =
VPQQT
PFQPQ
OHPYM
XWAPM

The method of randword is to select a random word from the
lexicographically sorted list of all words on alpha of length
wordSize. With n = length(alpha) and w = wordSize, the steps
are
1) Get a random number r on the interval 1:n^w.
2) Compute base n expansion of r.
3) Make word with symbols of 'alpha' indexed by
base n digits of r.

Author: Tom Richardson
trichardson AT xrite DOT com
Date: 14 July 2009

Changed the routine to use multiple passes to ensure that values of
lexIndex stay below 2^31 - 1, thus avoiding roundoff error in
alphaSize.
Modified: Tom Richardson
Date: 21 January 2010

引用

Thomas (2025). RANDWORD (https://www.mathworks.com/matlabcentral/fileexchange/24730-randword), MATLAB Central File Exchange. に取得済み.

MATLAB リリースの互換性
作成: R2009b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersCall Python from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.1.0.0

Changed the routine to use multiple passes to ensure that values of
lexIndex stay below 2^31 - 1, thus avoiding roundoff error in
alphaSize.
Modified: Tom Richardson
Date: 21 January 2010

1.0.0.0