Matlab Subclass Question

Question about subclasses in matlab, in the new class system. I have class A with some protected properties:

classdef Table < Base

properties (SetAccess = protected, GetAccess = public)
    PropA = [];
end %properties

I would like to create a subclass with some specialized functions and further restrict access to PropA. (i.e. make access private in a subclass). My first thought was:

classdef subTable < Table

...
methods (Access = private)
    out = get.PropA(obj, value);
end %private methods

However, the help says: "You must define methods for accessing properties in a method block that does not specify any attributes." So much for this idea.

Any ideas?

+3
source share
1 answer

I do not think this is possible. From the MATLAB Documentation :

There are only two conditions that allow you to override the properties of a superclass:

  • true
  • SetAccess, GetAccess, private

, . . , , . PropA, subTable.

+4

Source: https://habr.com/ru/post/1706624/


All Articles