フィルターのクリア

filter table by character string entry

103 ビュー (過去 30 日間)
Dan H
Dan H 2019 年 1 月 30 日
Hello,
I have table T which contains string entries in the second column (named 'column_name').
Two questions:
  1. How can I filter the table (or create a new table), so that only those rows are included whose 2nd column entry equals the filter parameter (e.g. 'FieldSlew1')?
  2. How can I filter the table (or create a new table), so that only those rows are included whose 2nd column entry contain the filter parameter (e.g. 'FieldSlew')?
For information regarding formats:
When querying, I get the following results
>> T(1, 2)
ans =
table
column_name
____________
'FieldSlew1'
I have tried using "for" loops, but this takes forever.
Thank you for advice,
Dan
  1 件のコメント
madhan ravi
madhan ravi 2019 年 1 月 30 日
upload your table as .mat file

サインインしてコメントする。

採用された回答

Andreas Kvalbein Fjetland
Andreas Kvalbein Fjetland 2019 年 1 月 30 日
編集済み: Andreas Kvalbein Fjetland 2019 年 1 月 30 日
Hi Dan,
try this method out.
%create random table
t1 = [1,2,3,4]';
t2 = {'Hei','boo','Hei','boo'}';
tbl = table();
tbl.t1 = t1;
tbl.t2 = t2;
% Convert to categorical, as i presume this is reoccuring values
tbl.t2 = categorical(tbl.t2)
% index rows with the correct variables in column
idx = tbl.t2 == 'boo';
% create table based on index
newtbl = tbl(idx,:);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by