Randomize a vector with letters making a N back test

1 回表示 (過去 30 日間)
basma awad
basma awad 2021 年 8 月 30 日
回答済み: Jan 2021 年 8 月 30 日
Hi,
I wish to create a random letter vector that has 150 element with only the letters from A to J, which i have done here:
s='A':'J'; % Generate the Letters from A to J
str=s(randi(numel(s),150,1))';
But i wish that some of the every 3rd element after 1 element is identical. For eksample
[A G J B G H D I H C]
Thank u

採用された回答

Jan
Jan 2021 年 8 月 30 日
s = 'A':'J';
str = s(randi(numel(s), 1, 150));
idx = 5:4:numel(str);
str(idx) = str(idx - 3)
str = 'FBJGBBHEBCICCJEFJFJDFDECDHAGHBAIBJDBJCEDCHCAHFDIFCHDCFIFFDFHDBFHBFEIFEJFEFACFHIAHICIIHEHHABHADJCDFCAFBIGBEIJEDIIDFEDFDCGDFJHFJHFJFCHFDBDDBDCBDJADAHAAE'

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by