에
'Sub1','Sub2','Super1','Super2'
을 설정하려면 : 메타 클래스는 부모 클래스를 정의와 속성에 대한 정보가 포함되어 있습니다. 아이디어는 클래스를 정의하고 클래스를 순서를 바꾸지 만 클래스 내에 순서를 유지하면서 속성 이름을 수집하여 속성을 거치게됩니다.
mkl = meta.class.fromName('MyClass');
% get number of properties and populate cell to hold names
n = numel(mkl.PropertyList);
pl = cell(n, 2);
for ii = 1:n
pl{ii, 1} = mkl.PropertyList(ii).Name;
pl{ii, 2} = mkl.PropertyList(ii).DefiningClass.Name;
end
% find unique defining classes, keeping their sort order
klasses = unique(pl(:,2), 'stable');
new_prop_list = {};
% go through class list in reverse, find defined properties, and append them
for ii = numel(klasses):-1:1
klass = klasses{ii};
kl_prop = strcmpi(klass, pl(:,2));
new_prop_list = [new_prop_list; pl(kl_prop, 1)];
end
당신은 메타 클래스를 조사 할 수있다 :'MC = meta.class.fromName ('MyClass에')'다음'에 정의 된 모든 속성을 포함 재산'PropertyList'를 포함 mc' 클래스 계층 구조. 각 속성 자체는 'DefiningClass'라는 속성을 가지고 있습니다.이 속성에는 속성이 정의 된 클래스에 대한 메타 클래스 객체가 들어 있습니다. 속성 이름과 정의 클래스 이름을 모두 수집하고 클래스를 정의하여 순서를 바꿀 수 있습니다. – zeeMonkeez