フィルターのクリア

Strcmp for two different Cells

5 ビュー (過去 30 日間)
Simon
Simon 2016 年 10 月 6 日
コメント済み: Simon 2016 年 10 月 6 日
Hello,
is it possible to compare two Cell-Variables with different sizes?
Example:
var1 = {'A', 'B', 'C'}
var2 = {'A', 'AA', 'B', 'BB', 'BB' , 'U' , 'V' , 'W' }
strcmp(var1,var2)
Result
>> ans = 1 0 1 0 0 0 0 0
The functions checks one element from var1 is existing in var2.

採用された回答

Guillaume
Guillaume 2016 年 10 月 6 日
Use ismember:
var1 = {'A', 'B', 'C'}
var2 = {'A', 'AA', 'B', 'BB', 'BB' , 'U' , 'V' , 'W'}
ismember(var2, var1)

その他の回答 (1 件)

Matthias Walle
Matthias Walle 2016 年 10 月 6 日
Do you mean like this?
strcmp(var1{1},var2) + strcmp(var1{2},var2) + strcmp(var1{3},var2)
and you want to use one single strcmp command?
  1 件のコメント
Simon
Simon 2016 年 10 月 6 日
Yes, Guillaume's post shows a solution. Thank you.

サインインしてコメントする。

カテゴリ

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