Is there any function in Matlab that can serve as "VLOOKUP" of Excel?
    9 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Jennifer Arellana
 el 27 de Abr. de 2021
  
    
    
    
    
    Comentada: Qishen Ye
 el 19 de En. de 2023
            I am making a model that gives me this information:
aux2 =
  7×2 cell array
    {'100'} {[8.7856e+08]}
    {'010'} {[7.8487e+09]}
    {'110'} {[8.7272e+09]}
    {'001'} {[5.4068e+09]}
    {'101'} {[6.2854e+09]}
    {'011'} {[1.3361e+10]}
    {'111'} {[1.4243e+10]}
The problem I have is that I need these results to have the following order (just look at column 1 to understand the order):
final1 =
  7×1 cell array
    {'100'}
    {'010'}
    {'001'}
    {'110'}
    {'101'}
    {'011'}
    {'111'}
I think that a solution could be something like what the Excel function "VLOOKUP" does, the logic of this is that it looks for each value of column 1 of the aux2 array in column 1 of the final array1 and assigns the value of column 2 of the aux2 array in the order of column 1 of the final array1.
This is an idea but if you can think of a better way, I would appreciate any help, thanks!
0 comentarios
Respuesta aceptada
  Fangjun Jiang
      
      
 el 27 de Abr. de 2021
        [~,index]=ismember(final1,aux2(:,1))
newData=aux2(index,:)
1 comentario
  Qishen Ye
 el 19 de En. de 2023
				Many Thanks! This function also works for matching data from multiple columns.
Más respuestas (0)
Ver también
Categorías
				Más información sobre Logical 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!


