title: Matlab: Reference to a handle object
body: <p>Can I create a reference to a handle object in a way that I can replace the object itself at one point and the references will be updated?</p>
  
  <p>Example:</p>
  
  <pre><code>classdef IShifter &lt; handle
    methods (Abstract)
      x = Shift(this, x);
    end
  end
  
  classdef Shifter1 &lt; IShifter
    methods
      function x = Shift(this, x)
        x = circshift(x, 1);
      end
    end
  end
  
  classdef Shifter2 &lt; IShifter
    methods
      function x = Shift(this, x)
        x = [ 0 ; x ];
      end
    end
  end
  
  
  
  classdef Item
    properties (Access = 'private')
      shifter; % should be a pointer/reference to the object which is in the respective parent container object
    end
  
    methods
      function this = Item(shifter)
        this.shifter = shifter;
      end
  
      function x = test(this, x)
        x = this.shifter.Shift(x);
      end
    end
  end
  
  % note this is a value class, NOT a handle class!
  classdef ItemContainer
    properties
       shifter;
       items;
    end
  
    methods
      function this = ItemContainer()
        this.shifter = Shifter1;
        this.items{1} = Item(this.shifter);
        this.items{2} = Item(this.shifter);
      end
  
      function Test(this)
        this.items{1}.Test( [ 1 2 3] )
        this.items{2}.Test( [ 1 2 3] )
      end
    end
  end
  </code></pre>
  
  <p>Then, the output should be:</p>
  
  <pre><code>items = ItemContainer();
  items.Test();
  [ 3 1 2 ]
  [ 3 1 2 ]
  items.shifter = Shifter2;
  items.Test();
  [ 0 1 2 ]
  [ 0 1 2 ]
  </code></pre>
  
  <p>But instead it is:</p>
  
  <pre><code>items = ItemContainer();
  items.Test();
  [ 3 1 2 ]
  [ 3 1 2 ]
  items.shifter = Shifter2;
  items.Test();
  [ 3 1 2 ]
  [ 3 1 2 ]
  </code></pre>
  
  <p>because assigning a new Shifter object to parent object items does not update the references in the containers.</p>
  
  <p>I am looking for something like in C where all the "shifter" properties are pointers and I can put whatever Shifter object I want into this "address".</p>
  
  <p>ItemContainer and Item are not handle classes.
  I want to avoid using events to update the references or implementing a set method to update the references</p>