MATLAB: How can i compare two string matrix with conditions

comaparisoncountmatrixstring

I want to compare two string matrix like a=[yes yes;no no] &b=[no yes;yes no] with conditions like if yes&yes=a;no&no=b;yes&no=c;no&yes=d..and i want to count no of common elements like 'no' (common in both matrix(a(2,2)&b(2,2)).

Best Answer

>> a={'yes','yes';'no','no'};
>> b={'no','yes';'yes','no'};
>> X = strcmp(cat(3,a,b),'yes');
>> Y = 1 + diff(X,1,3) + 2*all(X,3)
Y =
0 3
2 1
Where 0=(yes,no), 1=(no,no), 2=(no,yes), 3=(yes,yes).
Related Question