how to generate all possible combinations of a 14x10 matrix containing only 1's and 0's

前端 未结 11 1029
悲&欢浪女
悲&欢浪女 2021-01-23 23:32

I\'m working on a problem and one solution would require an input of every 14x10 matrix that is possible to be made up of 1\'s and 0\'s... how can I generate these so that I can

11条回答
  •  天涯浪人
    2021-01-24 00:14

    Here is an efficient way to do get started Matlab:

    First generate all 1024 possible rows of length 10 containing only zeros and ones:

    dec2bin(0:2^10-1)
    

    Now you have all possible rows, and you can sample from them as you wish. For example by calling the following line a few times:

    randperm(1024,14)
    

提交回复
热议问题