如果我有以下课程:
classdef foo
properties
bar1
bar2
bar3
end
properties(Access = private)
bar4
bar5
end
end
并执行以下操作:
myObj = foo();
test = struct(myObj);
test
将具有foo
as 字段的所有 5 个属性,包括私有属性:
test =
bar1: NaN
bar2: NaN
bar3: NaN
bar4: NaN
bar5: NaN
我希望创建一个只有myObj
as 字段的公共属性的结构:
test =
bar1: NaN
bar2: NaN
bar3: NaN
如何从对象中提取仅包含公共属性的结构?