vlookup fuction for matlab

조회 수: 5 (최근 30일)
Anfal Abdulrahman
Anfal Abdulrahman 2017년 4월 9일
댓글: Andres Bergsneider 2020년 5월 29일
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

채택된 답변

the cyclist
the cyclist 2017년 4월 9일
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);
  댓글 수: 2
Anfal Abdulrahman
Anfal Abdulrahman 2017년 4월 10일
Thank you very much worked perfectly :)
Andres Bergsneider
Andres Bergsneider 2020년 5월 29일
Woaa, thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

the cyclist
the cyclist 2017년 4월 9일
Someone has contributed this vlookup function to the File Exchange. I haven't used it myself, so I can't comment on how well it works.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by