How can I show equality in cell arrays?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponse acceptée
Walter Roberson
le 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 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!