Get data from table with two conditions

6 ビュー (過去 30 日間)
Aram Eskandari
Aram Eskandari 2019 年 3 月 30 日
回答済み: madhan ravi 2019 年 3 月 30 日
See attached picture for a small part of the table. I'm trying to get the column "ahe" as a separate vector, but only include every row that has year 2012, and bachelor 0.
To create the vector and only include every row that has year 2012, I used this line, where T is the table;
T{T.year==1992,'ahe'}
I tried using this to include the bachelor requirement;
T{T.year==1992 && T.bachelor==0, 'ahe'}
But I couldn't get it to work. Any help would be greatly appreciated.

採用された回答

madhan ravi
madhan ravi 2019 年 3 月 30 日
T{(T.year==1992) & (T.bachelor==0), 'age'}
% ^ ^
% or
T{(T{:,'year'}==1992) & (T{:,'bachelor'}==0), 'age'}

その他の回答 (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