フィルターのクリア

hi,,is there any way,I can generate a vector with 10 bit with only zero and 25?

1 回表示 (過去 30 日間)
the vector should be like this, A=[0 0 25 25 25 0 0 25 0]...or anything that has only zero and 25.number of 25 is not important..TIA

採用された回答

Walter Roberson
Walter Roberson 2016 年 5 月 23 日
TheConstant = 25;
HowMany = 10;
binary = rand(1,HowMany) < 0.5;
result = binary * TheConstant;
Or in short,
result = (rand(1,10) < 0.5) * 25;
  2 件のコメント
nafila aytija
nafila aytija 2016 年 5 月 23 日
Thank you very much..it works perfectly fine
Walter Roberson
Walter Roberson 2016 年 5 月 23 日
Alternately:
result = randi([0 1], 1, 10) * 25;

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSources についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by