0
構造体のクラスプロパティに関数を追加することはできますか?目的の使用法: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 –