フィルターのクリア

How to extract rows from a table based on the categories present in one of the columns?

2 ビュー (過去 30 日間)
I have created a table that has double and categorical columns.How can I extract the rows that correspond to each one of the categories?
Being more specific, the table is called 'Plate' and one of the columns 'Invivo'.
If I write
categories(Plate.Invivo);
The answer gives me three categories
'Drug'
'Positive control'
'mock'
If I write
b=Plate(Plate.Invivo=='Drug',:);
The answer is a table with 0 rows and the same number of columns as the original table. Why it can not find the rows that correspond with the categorie 'Drug'?
Thanks a lot for your help
  2 件のコメント
madhan ravi
madhan ravi 2020 年 6 月 19 日
Mind sharing the table?
Ildefonso Vicente Suarez
Ildefonso Vicente Suarez 2020 年 6 月 20 日
Please find attached to this comment the table I was talking about . Thanks a lot for your help!

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

採用された回答

Esperanza Linares Guerrero
Esperanza Linares Guerrero 2020 年 6 月 22 日
The reason why you are getting an empty array, is because your category is not Drugs, it is 'Drugs' (between quotes). You can remove the quotes from the table and the command would work, or, you can define a variable that contains the quotes:
a=Plate.Invivo(end);%%% Checking your table, the last row has the 'Drugs' category
b=Plate.Invivo(Plate.Invivo==a,:)
  2 件のコメント
Ildefonso Vicente Suarez
Ildefonso Vicente Suarez 2020 年 6 月 22 日
Thank you!. That worked
Esperanza Linares Guerrero
Esperanza Linares Guerrero 2020 年 6 月 22 日
Alternatively use:
b=Plate.Invivo(Plate.Invivo=='''Drug''',:)

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

その他の回答 (1 件)

KSSV
KSSV 2020 年 6 月 19 日
編集済み: KSSV 2020 年 6 月 19 日
b=Plate(strcmp(Plate.Invivo,'Drug'),:);
  1 件のコメント
Ildefonso Vicente Suarez
Ildefonso Vicente Suarez 2020 年 6 月 20 日
Thanks a lot for answering my question. When I used your line of code the answer is a table with 0 rows.
I am attaching the table to this comment.

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by