vlookup fuction for matlab

115 ビュー (過去 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 件のコメント
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.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by