Trying to predict equality between cell arrays

4 Ansichten (letzte 30 Tage)
Mahendran Subramanian
Mahendran Subramanian am 3 Okt. 2019
I have two cell arrays A and B
A 400 x 1 cell
{1 x 5 categorical
1 x 5 categorical
1 x 5 categorical
.......}
B 400 x 1 cell
{1 x 5 categorical
1 x 5 categorical
1 x 5 categorical
.......}
I tried to do
C = sum(B == A)./numel(A)
And I am getting the following error
Undefined operator '==' for input arguments of type 'cell'.
Then I tried the following
C = sum(B{:} == A{:})./numel(A{:})
And I am getting the folowing error
Error using ==
Too many input arguments.

Antworten (1)

David Hill
David Hill am 3 Okt. 2019
If you are just testing equality between the whole cells use:
isequal(A,B);
  1 Kommentar
Mahendran Subramanian
Mahendran Subramanian am 3 Okt. 2019
I am not after isequal !
Anyway I got it to work by using a simple for loop.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Categorical Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by