Suppose I have a cell array containing an array of integer arrays. What is the best way to search the cell array for a specific array and return true if it exists and false otherwise?
1 Answer
You can use cellfun combined with isequal:
For example:
cellArr = {[1 2 3],'xcxc',magic(5),1:3};
element = [1 2 3];
indexes = cellfun( @(x)isequal(x,element),cellArr);
This will give you an array that contains true in the cells that the element exists.
In order to check whether the element exists at least once, just use:
any(indexes)