Look for string in table and return a number in the same row different column
1 回表示 (過去 30 日間)
古いコメントを表示
Hi i have a table named TurbulentFittings.xlsx
and i am trying to return values from speKL column by using fitcode entries kind of like VLOOKUP but for string lookup.
here's my code
KLDATA = readtable("TurbulentFittings.xlsx")
fitcode = app.FittingCodeEditField.Value %Fitcode entry
speKL = vlookup("fitcode",KLDATA,2,3,0) %how do i look for the speKL value in the same row as the fitcode? vlookup doesnt work
1 件のコメント
Sargondjani
2021 年 9 月 21 日
The function "find" is what you need. Maybe search for "find string in matrix" or in a table
採用された回答
Steven Lord
2021 年 9 月 21 日
I'd probably use matches for text data (and the normal relational operators for numeric data.)
load patients
P = table(LastName, Age, Gender, Height, Weight);
head(P)
Now let's find all patients that are male and are at least 40 years old.
areMale = matches(P.Gender, 'Male'); % Use matches for text
are40OrOlder = P.Age >= 40; % Use relational operators for numbers
P(areMale & are40OrOlder, :)
The row for Mr. Smith, row 1 in P, doesn't show up because he's not old enough. The row for Mr. Johnson, row 2 in P, does show up because he's a male over 40. None of the next 5 lines show up because those patients aren't male. If I'd wanted I could have just gotten the heights of those patients.
% Use curly braces to extract the contained data not a subtable
H = P{areMale & are40OrOlder, 'Height'}
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!