find array equal and put it in group?
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Le Xuan Thang
 el 29 de Dic. de 2019
  
    
    
    
    
    Editada: Thiago Henrique Gomes Lobato
      
 el 29 de Dic. de 2019
            Hello guys! i have a problem.
i have matrix:
A = [1	0	0	0	0
    0	1	0	0	1
    0	0	1	0	0
    0	0	0	1	0
    0	1	0	0	1]
and i want to find each total row or column equal then put it in group like:
group 1 = row1;
group 2 = row 3
group 3 = row 2, row 5;
group4 = row 4
plz help me. tks.
0 comentarios
Respuesta aceptada
  Thiago Henrique Gomes Lobato
      
 el 29 de Dic. de 2019
        
      Editada: Thiago Henrique Gomes Lobato
      
 el 29 de Dic. de 2019
  
      This is one of the basic functionalites of the unique function, just do something like this:
A = [1	0	0	0	0
    0	1	0	0	1
    0	0	1	0	0
    0	0	0	1	0
    0	1	0	0	1];
[C,ia,ic] = unique(A,'rows');
ic
ic =
     4
     3
     2
     1
     3
The ic vector is saying for which group each row belongs
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Logical en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!