Get properties from another class (matlab) -
is possbile properties class in matlab?
i have 2 classes: projecttable
and allprojecttables
.
in projecttable
have tried following:
properties (getaccess = ?allprojecttables)
but doesn't work.
here working example:
classdef projecttable properties (getaccess = ?allprojecttables) value end methods function obj = projecttable(val) obj.value = val; end function r = addtwo(obj) r = obj.value + 2; end end end classdef allprojecttables properties project_table end methods function obj = allprojecttables(project_table) obj.project_table = project_table; end function r = test(obj) r = obj.project_table.value; end end end
and test:
>> a=projecttable(45) = projecttable no properties. >> a.value cannot 'value' property of projecttable. >> b=allprojecttables(a) b = allprojecttables properties: project_table: [1x1 projecttable] >> b.test ans = 45 >> b.project_table.value cannot 'value' property of projecttable. >>
Comments
Post a Comment