Find where two cell arrays of different sizes are equal
21 views (last 30 days)
Camille Woicekowski on 22 Sep 2020
I have two cell arrays of different sizes filled with chars. I want to loop through and find the indices of one cell where the char values are equal to each other.
should return 1 and 5 if I loop through cell one.
If these were doubles, I would use
but with these variable types I'm having some trouble.
return the logcial True but
returns the error message "Operator == is not supported for opperands type cell". I also tried using cellfun(@isequal, cell1, cell2) but I get an error message because the size and shape of my cells are not equal.
How can I get the desired result using these variable types?
Ameer Hamza on 22 Sep 2020
Edited: Ameer Hamza on 22 Sep 2020
To compare char arrays, strcmp() should be used. However, since you are using the lastest version of MATLAB, so there are easier ways
idx = find(any(string(cell1) == string(cell2).'));