フィルターのクリア

Finding position of a string in a cell array

66 ビュー (過去 30 日間)
yashvin
yashvin 2015 年 7 月 30 日
回答済み: Azzi Abdelmalek 2015 年 7 月 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?

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 30 日
s={'AGGH' '' 'ANYN' '' 'AYBK' '' 'AYDU' '' 'AYGB' }
find(strcmp(s,'ANYN' ))

その他の回答 (1 件)

Walter Roberson
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.

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by