4 matrix generation depending on a specific value,
显示 更早的评论
i want to generate a matrix of all possible binary combinations dpeending on a specfic 1x4 vector, and the vector elements are randomly generated from 1:4.
for example if the vector is [2 3 2 4], the first matrix should be all possible combinations of 2 bits
[0 0; 0 1; 1 0 ; 11]
, the second matrix should be all possbile combinations of 3 bits,
[ 0 0 0; 0 0 1; 0 1 0; 0 1 1; 1 0 0; 1 0 1; 1 1 0 ; 1 1 1]
and so on..
采纳的回答
更多回答(1 个)
KSSV
2020-10-1
s = [0 1] ;
iwant1 = npermutek(s,2) ;
iwant2 = npermutek(s,3) ;
iwant3 = npermutek(s,4) ;
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!