【发布时间】:2013-05-23 08:54:23
【问题描述】:
(如何)我可以在 Matlab 中动态访问嵌套字段吗?我正在考虑这样一个测试用例:
a = struct;
a.foo.bar = [];
place = {'foo', 'bar'};
a.(place{:})
% instead of the following, which only works if know in advance
% how many elements 'place' has
a.(place{1}).(place{2})
【问题讨论】:
-
可以,但不止一层。