Hi,
I am trying to select a subset from a dataset using the following command:
if true
t = readtable('my_table.csv');
data = table2dataset(t);
M_L = data(data.System=='M' & data.Hemisphere=='L',:);
M_R = data(data.System=='M' & data.Hemisphere=='R',:);
end
But I am getting an error: Undefined operator '==' for input arguments of type 'cell'.
Any ideas how to fix that? I will need to select mulpitle subsets with different variables, so I would prefer not to use strcmp or strmatch.

 採用された回答

Kevin Chng
Kevin Chng 2018 年 12 月 17 日

0 投票

Undefined operator '==' for input arguments of type 'cell'.
The operator is not for cell. Therefore, you have to convert the cell type to matrix first. However, i'm not sure whether data.System or data.Hemisphere is cell type, or both are cell type.
try
if true
t = readtable('my_table.csv');
data = table2dataset(t);
M_L = data(cell2mat(data.System)=='M' & cell2mat(data.Hemisphere)=='L',:);
M_R = data(cell2mat(data.System)=='M' & cell2mat(data.Hemisphere)=='R',:);
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLanguage Support についてさらに検索

タグ

質問済み:

2018 年 11 月 8 日

回答済み:

2018 年 12 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by