Random symbol generation in matlab

3 ビュー (過去 30 日間)
chaaru datta
chaaru datta 2024 年 2 月 11 日
回答済み: Shivam 2024 年 2 月 11 日
How to generate multiple (256) symbols of -1 and 1 in MATLAB
Any help in this regard will be highly appreciated.
  2 件のコメント
Austin M. Weber
Austin M. Weber 2024 年 2 月 11 日
Can you be more specific about what you want? For instance, are you asking for a way to create a 256-element array containing a bunch of -1s and 1s?
chaaru datta
chaaru datta 2024 年 2 月 11 日
Yes sir...

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

採用された回答

Shivam
Shivam 2024 年 2 月 11 日
Hi,
To achieve an array of 256 element containing -1s and 1s, you can follow the below workaround:
% Generate a 256-element array of random 1s and 2s
randomIntegers = randi([1, 2], 1, 256);
% Map 1s to -1s and 2s to 1s
arrayOfMinusOnesAndOnes = 2 * randomIntegers - 3;
I hope it works.
Thanks.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by