How can I show equality in cell arrays?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Walter Roberson
2016 年 10 月 29 日
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)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!