Or statement for input arguments of type 'cell'

1 次查看(过去 30 天)
Hi, I want to compare two arguments of cell type which I read as readtable from a csv file (with header). I need to use Or statement but I get error that is not possible to do that.
T=readtable('r.csv')
if strcmp(T.first | T.second , 'NONE')==0
....
end
error: Undefined operator '|' for input arguments of type 'cell'
can you please me help me?

采纳的回答

Rik
Rik 2018-6-18
The ismember function should help you out here, or you can use multiple calls to strcmp:
T=readtable('r.csv');
if ~( strcmp(T.first, 'NONE') || ...
strcmp(T.second, 'NONE') )
...
end
  2 个评论
Jan
Jan 2018-6-18
+1. If T.first and T.second are cell arrays, an any or all might be wanted. Or perhaps:
index = ~(strcmp(T.first, 'NONE') || strcmp(T.second, 'NONE'));

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by