How to compare strings in a cell

1 次查看(过去 30 天)
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

采纳的回答

per isakson
per isakson 2018-2-24
编辑:per isakson 2018-2-24
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by