MATLAB object property visible but not modifyable

Viewed 62

I want to have a property of an object be visible to the user, but not modifiable by the user. I've tried the following

classdef myObject < handle

    properties (Access = private, Hidden = false)
        property
    end 

but this one remains hidden to the user, and I can't find anything in the documentation that would do this. Is there a way to make the property "read-only"?

1 Answers

Besides the Access property, there are also GetAccess and SetAccess properties. See the documentation for these.

classdef myObject < handle

    properties (SetAccess = private)
        property
    end 

Note that Access is a pseudo-property, a short-hand to set both GetAccess and SetAccess to the same value.

Related