Finding position of a string in a cell array
61 次查看(过去 30 天)
显示 更早的评论
Hello, please find below my code:
Airport_data(1:10)
ans =
'AGGH' '' 'ANYN' '' 'AYBK' '' 'AYDU' '' 'AYGB' ''
>> Airport_actual
Airport_actual =
'ANYN'
>> whos Airport_data
Name Size Bytes Class Attributes
Airport_data 1x4835 555792 cell
>> whos Airport_actual
Name Size Bytes Class Attributes
Airport_actual 1x1 120 cell
i want to find the index of 'ANYN' which in this case is 3. How can i do this.? Should i convert to string first?
0 个评论
采纳的回答
Azzi Abdelmalek
2015-7-30
s={'AGGH' '' 'ANYN' '' 'AYBK' '' 'AYDU' '' 'AYGB' }
find(strcmp(s,'ANYN' ))
0 个评论
更多回答(1 个)
Walter Roberson
2015-7-30
[tf, idx] = ismember(Airport_actual, Airport_data);
tf will be true if it is found, and idx will be the index it was found at.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!