Skip to content

Instantly share code, notes, and snippets.

@tuix
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuix/ed9b1d312f00dc566251 to your computer and use it in GitHub Desktop.
Save tuix/ed9b1d312f00dc566251 to your computer and use it in GitHub Desktop.

If you add a changex0 method to the superclass that has (SetAccess=private)

classdef Rectangle
    properties (SetAccess=private)
        width
        height
        x0 = 0
        y0 = 0
        angle = 0
    end
    methods
        function obj = Rectangle(x0, y0, width, height, angle)
            obj.x0 = x0;
            obj.y0 = y0;
            obj.width = width;
            obj.height = height;
            obj.angle = angle;
        end
        
        function obj = changex0(obj, newx)
            obj.x0 = newx;
        end
    end
end

and a is an object from class Rectangle you can still change the value by

a = a.changex0(22);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment