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

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...

댓글 수: 1

Seems it is not possible? Matlab may consider adding this function.

댓글을 달려면 로그인하십시오.

 채택된 답변

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개)

카테고리

도움말 센터File Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

질문:

2013년 10월 8일

댓글:

2013년 10월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by