Is it possible to define the properties for a class using cell array?

4 次查看(过去 30 天)
For example, I have a cell array AA={'x' 'y' 'z'} obtained by reading external files such as Excel table. How can I define the properties x, y, z for a class by referring to AA or a function with output AA. Is this possible?
instead of:
classdef T
properties
x
y
z
end
end
I want something like:
classdef T
properties
AA's elements
end
end
Thanks...

采纳的回答

Sean de Wolski
Sean de Wolski 2013-10-9
编辑:Sean de Wolski 2013-10-9
Ycan have your class inherit from DynamicProps and this will allow you to add properties dynamically.
C = {'x','y','z'};
D = exampleDynProp; %attached
for ii = 1:numel(C);addprop(D,C{ii});end
D

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Properties 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by