how to store more than one value in same cell array when we loop

조회 수: 2 (최근 30일)
ZeKkEn NoName
ZeKkEn NoName 2021년 1월 31일
답변: Shubham Rawat 2021년 2월 3일
I need to store more than one value in the cell but it only store the last value ? is there way can i define array with different size inside the cell ?
CellVoronoiMapping = cell(n , 1) ;
for i = 1 : ength(MBR)
CellIDs = ListOfCellsID{i};
for j = 1 : length(CellIDs)
if (overlaps(ListVoronoiPolygon{i} , ListCellPolygon{CellIDs(j)})==1)
CellVoronoiMapping{CellIDs(j)} = i;
end
end
end

답변 (1개)

Shubham Rawat
Shubham Rawat 2021년 2월 3일
Hi,
Yes we can create a cell array with elements in it having different lengths. You may look at the code:
Cell_array = cell(3,1);
Cell_array{1} = [1,2,3,4];
Cell_array{2} = [1,2];
Cell_array{3} = [];
size(Cell_array{2}) %here size is 1*2
ans =
1 2
size(Cell_array{1}) %here size is 1*4
ans =
1 4
Hope this Helps!

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by