Effacer les filtres
Effacer les filtres

How to compare strings in a cell

1 vue (au cours des 30 derniers jours)
Jab
Jab le 24 Fév 2018
Modifié(e) : per isakson le 24 Fév 2018
I have a cell R={Transport.name}; which is 1*20 cell
I want to check my input string( from the user) will exist in R or not? Can anyone please help me? Thanks

Réponse acceptée

per isakson
per isakson le 24 Fév 2018
Modifié(e) : per isakson le 24 Fév 2018
Try this
%%Sample data
str = char(randi(double(['A','Z']),[20,3] )); % Too smart
cac = mat2cell( str, ones(1,20),3 );
R = cac';
input_string = R{13};
%%Check if input_string exists in R
ismember( input_string, R )
returns
ans =
1

Plus de réponses (0)

Catégories

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

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by