Cell contents reference from a non-cell array object ERROR in the following function

function y = edgeindex(edgenum, indexes, id)
length_index = length(indexes);
y = cell(1,edgenum);
b = 0;
for i = 1:length_index
l = indexes(i)
a = id(1);
if i == 1
c = strsplit(char(a),'_');
b = b+1;
y{b} = l;
else
d = strsplit(char(a),'_');
if c{3} ~= d{3}
c = d;
b=b+1;
y{b} = l;
elseif c{3} == d{3}
y{b} = [y{b}{l}]
end
end
end
Edgenum - an integer
Indexes - an array of integers
id - is a column vector made of text ex. OUT_218_46_[1][0].
My goal is to be able to create a cell array (y in this case) where each cell includes all of the indexes with the same string between the second and third '_'.
I can't see what is wrong with my code, but I get this error @ y{b} = [y{b} {l}] :
Cell contents reference from a non-cell array object .
Thank you in advance.

 Accepted Answer

= [y{b} (l)] :
The {} are for extracting from a cell and () are for indexing into the elements in the cell since it will not be a cell.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!