Effacer les filtres
Effacer les filtres

Or statement for input arguments of type 'cell'

1 vue (au cours des 30 derniers jours)
hoda kazemzadeh
hoda kazemzadeh le 18 Juin 2018
Commenté : hoda kazemzadeh le 18 Juin 2018
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?

Réponse acceptée

Rik
Rik le 18 Juin 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 commentaires
Jan
Jan le 18 Juin 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'));
hoda kazemzadeh
hoda kazemzadeh le 18 Juin 2018
Thanks for your reply.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by