NSTRUCT2CELL

版本 1.0.0.0 (1.4 KB) 作者: Mathias Benedek
Conversion of nested structure to cell, providing overview and easy access to all sub-fields
357.0 次下载
更新时间 2011/1/4

查看许可证

C = NSTRUCT2CELL(S)

Recursive function that converts a nested struct S with a total of n sub-fields into a nx2 cell array C.
The first column of C lists the full names of the sub-fields and the second column contains the respective content.
In order to display long field names set format to long.

Example:

S.a.b = 1:3;
S.a.c = 1:6 > 3;
S.d(1).e = {'ABC','DEF'};
S.d(2).f = 'text';

S
S =
a: [1x1 struct]
d: [1x2 struct]

C = nstruct2cell(S)
C =
'S.a.b' [1x3 double ]
'S.a.c' [1x6 logical]
'S.d(1).e' {1x2 cell }
'S.d(1).f' []
'S.d(2).e' []
'S.d(2).f' 'text'

C{3,2}
ans =
'ABC' 'DEF'

引用格式

Mathias Benedek (2024). NSTRUCT2CELL (https://www.mathworks.com/matlabcentral/fileexchange/29908-nstruct2cell), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2008a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Data Type Conversion 的更多信息
致谢

启发作品: getnestedfield

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0