jeudi 5 mai 2016

how to generate a random binary matrix with a specific condition in matlab?

if matrix A shows the number of group of ones in G (n,m) matrix like that

G = [ 1 1 0 0 1 
      0 1 1 1 0
      1 0 1 1 1 ] 

so the A matrix will be

A = [ 2 1
      3 0
      1 3 ]

Then i want to generate (n,m) random matrix which the ones in this Matrix depend on A in the same order they appear

one solution will be

x = [ 0 1 1 0 1
      0 0 1 1 1
      1 0 1 1 1 ]

another solution

x = [ 1 1 0 1 0
      1 1 1 0 0
      1 0 1 1 1 ]




Aucun commentaire:

Enregistrer un commentaire