How to select the indices of two arrays that satisfy two conditions using cellfun (no loops or ifs)?
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    German Preciat Gonzalez
 el 22 de Ag. de 2018
  
    
    
    
    
    Comentada: German Preciat Gonzalez
 el 22 de Ag. de 2018
            Let's say I have two arrays:
 A = {'one(1)', 'two(1)', 'three(2)', 'four(2)', 'five(1)'};
 B = {'One', 'TWo', 'thrEE', 'Four', 'fiVe'};
I need to know the indices in the array A that have a: (1) and in the array B only one capital letter. For this example the indices are:
 idx = [1, 5]
Could you recommend me something using cellfun or something else without loops or ifs?
Thanks in advance
0 comentarios
Respuesta aceptada
  Fangjun Jiang
      
      
 el 22 de Ag. de 2018
        
      Editada: Fangjun Jiang
      
      
 el 22 de Ag. de 2018
  
      IndA=contains(A,'(1)');
IndB=cellfun(@(x) sum(x)==1, isstrprop(B,'upper'));
Index=find(and(IndA,IndB))
Más respuestas (0)
Ver también
Categorías
				Más información sobre Cell 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!

