I want to generate five matrices [5X10] of '0's and '1's with random generation in which each row may contain maximum one '1'. And with some special interdependence between rows.
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    MANISH KUMAR
 el 5 de Jul. de 2016
  
    
    
    
    
    Editada: Azzi Abdelmalek
      
      
 el 5 de Jul. de 2016
            For example if 1st row contains '1' then 4th and 5th rows should not contain any '1'.
Similarly
if 2nd row contains '1' then 4th row should not contain any '1'.
if 3rd row contains '1' then 5th row should not contain any '1'.
if 4th row contains '1' then 1st and 2nd rows should not contain any '1'.
if 5th row contains '1' then 1st and 3rd rows should not contain any '1'.
Example Matrix
X = [0 0 0 0 1 0 0 0 0 0; 0 1 0 0 0 0 0 0 0 0; 0 0 1 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0]
0 comentarios
Respuesta aceptada
  Azzi Abdelmalek
      
      
 el 5 de Jul. de 2016
        
      Editada: Azzi Abdelmalek
      
      
 el 5 de Jul. de 2016
  
      A=rand(5,10)>0.95
if any(A(2,:))
  A(4,:)=0
end
if any(A(3,:))
  A(5,:)=0
end
if any(A(4,:))
  A(2,:)=0
end
if any(A(5,:))
  A([1 3],:)=0
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

