Clear Filters
Clear Filters

How can I show equality in cell arrays?

3 views (last 30 days)
Hi, I have an array like this:
P = cell (50 , 5);
each cell in the first column of this array is a 4x960 matrix with 0/1 elements. I used a function like this:
for i = 1:50
F{i,2} = f(P{i,1})
end
in order to use 'f' function for each cell of column '1'. Now the 'f' function is like this:
function b = f ( a )
b = cell(4,16);
j=0;
for i = 1:4
for k = 1:960
jp=j;
j= ceil (k/60);
if j~=jp
counter=2;
end
if a(i,k) == 1
b{i, j}(counter) = k;
counter = counter + 1;
end
b{i,j}(1) = counter - 2;
end
counter = 2;
end
in this function, 'a' is one cell from column '1' in 'P'. It start to check each element in 'a' and return the distance between two consecutive '1' values, and also puts the returned values of each block of 1x60 in one cell in b array. So 'b' would be a 4x16 cell array and each cell hase undefined length.
the code and the function work correctly but when I want to use this function in different iterations, in the second iteration I get this error:
??? Undefined function or method 'eq' for input arguments of
type 'cell'.
Error in ==> f at 14 if a(i,k) == 1
Would you please help me with this?

Accepted Answer

Walter Roberson
Walter Roberson on 29 Oct 2016
If you are getting that error, the implication is that there is some P{i,1} which is a cell instead of being a numeric array. You must have constructed P incorrectly, such as if you had
P{i,1} = cellfun(..., 'Uniform', 0)
  1 Comment
Sherwin
Sherwin on 29 Oct 2016
Edited: Sherwin on 29 Oct 2016
Thank you so much for your help.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!