MATLAB: Vlookup fuction for matlab

vlookup

Greetings all,
I have table with a size 54 by 4 I need to use something equivalent to the vlookup(lookup val, table, column index) (i.e. vlookup(3.4,tableA,3) in matlab. would appreciate your help here 🙂
Thank you

Best Answer

Here is one way:
% The input matrix
M = magic(5);
% Input for element to find
elementToFind = 23;
colToReturn = 4;
% The algorithm
[tf,rowWithElement] = ismember(elementToFind,M(:,1));
output = M(rowWithElement,colToReturn);