MATLAB: Finding some specific numbers in a numeric cell array

cell arrays

I have a cell array that its cells contain numeric arrays of different sizes. each numeric array contains various number of numbers ranging from 7 to 13. i want to find the number and location of occurrences of all the 7s,8s,9s …and 13s in the whole cell array. i used the following function:
I = cellfun(@(x) find(x==7), new_data, 'UniformOutput', false);
for finding 7 for example. new_data is my array. i encounter this error after running it:
Undefined function or method 'eq'for input arguments of type 'cell'.
can any body help me in this regard?

Best Answer

Looks like you've nested the cell array; either create an array of cells with the double arrays each per cell or dereference inside your anonymous function--example:
>> dat(1)={randi([7 13],10,1)}; % make sample cell array
>> dat(2,1)={randi([7 13],8,1)}; % two cells w/ a double array in each
>> whos dat
Name Size Bytes Class Attributes
dat 2x1 264 cell
>> dat
dat =
[10x1 double]
[ 8x1 double]
>> cellfun(@(x) find(x==7), dat, 'UniformOutput', false)
ans =
[3x1 double]
[ 5]
>> ans{:}
ans =
7
9
10
ans =
5
>> data={dat} % now nest that in a single cell...
data =
{2x1 cell}
>> cellfun(@(x) find(x==7), data, 'UniformOutput', false)
Undefined function 'eq' for input arguments of type 'cell'.
Error in @(x)find(x==7)
>>
Look familiar??? :)
>> cellfun(@(x) find(x==7), data{:}, 'UniformOutput', false)
ans =
[3x1 double]
[ 5]
>> whos data
Name Size Bytes Class Attributes
data 1x1 324 cell
>>
NB: The curlies "{:}" to dereference the content of the cell in the latter...