필터 지우기
필터 지우기

How to store various data types in a nested cell structure?

조회 수: 4 (최근 30일)
Ali
Ali 2020년 7월 16일
편집: Ali 2020년 7월 16일
I'd like to have a cell structured as the following, where each row corresponds to a pointCloud object along with its information computated before hand, where id and size column hold numbers, type column holds text, ptCloud column holds the actual pointCloud object and segmentsArray contains another 1xN cell that holds the ptCloud's segmented point cloud objects.
  • How is storing and retrieval implemented?
  • I know I should use curly braces for refering to cell's contents, but with respect to nested cells if were to use this in 'for loop' how should I implement it?
  • Also for retrieval of each rows information in a 'for loop' what is the proper approach?
And if cells are not suitable for holding various data types at once, what other options do I have?
id type ptCloud segmentsArray size
myCell = [ 1 'trees' ptcObject (nested 1xN cell) 8000
2 'roads' ptcObject (nested 1xN cell) 5000
....]

채택된 답변

Arthur Roué
Arthur Roué 2020년 7월 16일
편집: Arthur Roué 2020년 7월 16일
Why not use a structure array with fields id, type, ptCloud, segmentsArray and size ?
myStruc(1) = struct('id', 1, 'type', 'trees', 'ptCloud', ptcObject, 'segmentsArray', (nested 1xN cell), 'Size', 8000)
myStruc(2) = struct('id', 2, 'type', 'roads', 'ptCloud', ptcObject, 'segmentsArray', (nested 1xN cell), 'Size', 5000)
...
Then you can access any element this way :
myStruct(2).Size
>> 5000
Imo, cell arrays are not the best way to organisze heterogeneous data.
  댓글 수: 1
Ali
Ali 2020년 7월 16일
편집: Ali 2020년 7월 16일
@Arthur I appreciate your elegant and concise answer, just what I was looking for, thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by