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일

1 개 추천

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일

0 개 추천

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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Types에 대해 자세히 알아보기

질문:

2016년 10월 6일

댓글:

2016년 10월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by