I have a 1×2 nested cell array A (cell array within a cell array):
A = 1×2 cell array {43612×7 cell} {863892×7 cell}
where
A{1} = {'Up' } {'Down' } {'Left' } {'Right'} {'BLUE'} {'1' } {'7' } {'1' } {'8' } {'3' } {'2' } {'7' } {'4' } {'3' } {'7' } {'9' } {'1' } {'6' } {'2' } {'1' } {'...' } {'...' } {'...' } {'...' } {'...' }A{2} = {'Up' } {'Down' } {'Left' } {'Right'} {'RED' } {'2' } {'1' } {'1' } {'1' } {'2' } {'6' } {'1' } {'7' } {'4' } {'2' } {'5' } {'9' } {'8' } {'4' } {'4' } {'...' } {'...' } {'...' } {'...' } {'...' }
If possible, by using only 1 or 2 lines of code, I would like to know if the text 'BLUE' is in A{1} or in A{2}.
The full answer would be: 'BLUE' is in A{1}(1,5), but I would like to know just the first index of A, i.e. either A{1} or A{2}.
Therefore, if we consider only the firs index of A, i.e. either A{1} or A{2}, my Result would be something like:
Result = 2x1 logical array 1 0
Which means my 'BLUE' text is in A{1}.
My first attempt started by using 'strcmp' in this way:
cellfun(@(x) strcmp(x, 'BLUE'), A, 'UniformOutput', false)
But then I got stuck… Any suggestion to get what I need in only 1 or 2 lines of code ?
Hope my question is clear enough…. Thanks a lot and best regards!
Best Answer