I want to add binary numbers randomly in a cell array. How to do it?
1 回表示 (過去 30 日間)
古いコメントを表示
Cell array
1 件のコメント
Marcel Kreuzberg
2021 年 7 月 29 日
write a random binary number (max 1024) randomly in a 10x10 cell array:
C{randi(10),randi(10)} = dec2bin(randi(1024))
回答 (1 件)
Johannes Hougaard
2021 年 7 月 29 日
I can't really get the desired output from Marcels comment. Maybe if you add it to a for loop it'll be feasible.
However I think this will do the trick
maxnum = 1024;
rowno = 10;
colno = 9;
C = cellfun(@dec2bin,num2cell(randi(maxnum,rowno,colno)),'UniformOutput',false);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!