cell2nestedstruct

版本 1.0.0.0 (1.6 KB) 作者: Todd Pataky
CELL2NESTEDSTRUCT converts an MxN cell array into a nested 1x1 structure array
745.0 次下载
更新时间 2006/5/30

无许可证

CELL2NESTEDSTRUCT provides an alternative method of constructing nested structures. It can be used with NESTEDSTRUCT2CELL (also available at MATLAB Central) for editing and visualizing 1x1 nested structures.

Example:

C = {'water' 'a' '' '' '' 111;...
'water' 'b' '' '' '' 222;...
'melon' '' '' '' '' [];...
'a' 'b' 'c' 'd' 'e' 'aaa';...
'q' 'r' '' '' '' cell(6,2)};
[S] = cell2nestedstruct(C);
[C2] = nestedstruct2cell(S);
isequal(C,C2)

ans =

1

S =
water: [1x1 struct]
melon: []
a: [1x1 struct]
q: [1x1 struct]

The structure is produced row-by-row using the general syntax:
S.row1.row2. ... rowN-1 = rowN;
Thus the following row of the cell array: {'water' 'a' '' '' '' 111}
is equivalent to entering:
S.water.a = 111;

引用格式

Todd Pataky (2026). cell2nestedstruct (https://ww2.mathworks.cn/matlabcentral/fileexchange/11215-cell2nestedstruct), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R13SP1
兼容任何版本
平台兼容性
Windows macOS Linux
版本 已发布 发行说明
1.0.0.0