How to delete the duplicate number or using unique in the cell?
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Hang Vu
 el 14 de Mayo de 2019
  
    
    
    
    
    Comentada: Hang Vu
 el 14 de Mayo de 2019
            Let's see if I have A:
A={[3];[6 8 3];[5];[10 5]}
I am trying to delete the duplicate numbers and found that 'unique' can return the array without the duplication. 
Is there any way that I can use unique or delete the duplicate to my cell structure? result like this for example:
A={[3];[6 8];[5];[10]}
0 comentarios
Respuesta aceptada
  Andrei Bobrov
      
      
 el 14 de Mayo de 2019
        A={[3];[6 8 3];[5];[10 5]};
k = repelem((1:numel(A))',cellfun(@numel,A));
B = cell2mat(cellfun(@(x)x(:),A,'un',0));
[a,b] = unique(B,'stable');
out = accumarray(k(b),a,[],@(x){x(:)'});
2 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Matrices and Arrays 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!