How to create a nested cell file?

2 ビュー (過去 30 日間)
Honey
Honey 2021 年 11 月 30 日
回答済み: Image Analyst 2021 年 11 月 30 日
Hi,
I want to have a cell file with 5 structs. In each struct, I should have two folder (A,B). Then, in each of these A and B, I want to have some folders up to 30 number. In each of these folders I should have a cell 12*31. Can I write it as below?
DATA{5}.A.B.C{12,31)=My data

採用された回答

Image Analyst
Image Analyst 2021 年 11 月 30 日
I assume you mean "fields" or "members" rather than folders (like operating system folders where files live).
Why do you want a cell array, with each of the 5 cells containing a single structure? It makes more sense to have a structure array.
Please review the FAQ on cell arrays.
For example, from the documentation:
field1 = 'f1'; value1 = zeros(1,10);
field2 = 'f2'; value2 = {'a', 'b'};
field3 = 'f3'; value3 = {pi, pi.^2};
field4 = 'f4'; value4 = {'fourth'};
s = struct(field1,value1,field2,value2,field3,value3,field4,value4)
s = 1×2 struct array with fields:
f1 f2 f3 f4
s is a 1x2 structure array because value2 and value3 have 2 values.

その他の回答 (1 件)

Chunru
Chunru 2021 年 11 月 30 日
DATA(5).A.B.C=rand(12,31);
DATA(1)
ans = struct with fields:
A: []
DATA(5)
ans = struct with fields:
A: [1×1 struct]

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by