0
struct 유형의 클래스 특성에 함수를 첨부 할 수 있습니까? 의도 된 사용 :Matlab 구조체에 함수 부착하기
% Definition:
classdef a < handle
properties
bar
end
methods
function obj = a()
obj.bar = struct;
%obj.bar.attachFunction('apply', @someFunction); <-- something like this
end
end
end
% Usage:
foo = a();
foo.bar.apply('test');
foo.bar.var1 = 1;
foo.bar.var2 = 2;
여기서 개체의 속성에 필드를 추가하고 있지만 인스턴스에 동적 속성을 추가하는 것이 좋습니다. 여기에 대해서는 https://www.mathworks.com/help/matlab/matlab_oop/dynamic-properties--adding-properties-to-an-instance.html에서 읽을 수 있습니다. –