Clear Filters
Clear Filters

Or statement for input arguments of type 'cell'

1 view (last 30 days)
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?

Accepted Answer

Rik
Rik on 18 Jun 2018
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 Comments
Jan
Jan on 18 Jun 2018
+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'));

Sign in to comment.

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!