title: Call method for object arrays in Matlab
body: <p>I have an array of objects (of user-defined class), and I want to call a method for all of them. The method represents a processing step for several data channels, tied with treir own objects. </p>
  
  <p>I see two solutions:</p>
  
  <p>1) Writing a for-loop to call method for every object in a vector:</p>
  
  <pre><code>for i=1:numel(objArray)
      objArray(i).step;
  end
  </code></pre>
  
  <p>2) Adding length check inside class method, like this:</p>
  
  <pre><code>function step(obj) 
      if numel(obj)&gt;1
          for i=1:numel(obj)
              step(obj(i));
          end
          return;
      end
      % some processing ...
  end
  </code></pre>
  
  <p>But I don't like both solutions, because I should add the same code for every method call in a first case or for every method definition in a second case. 
  Is there a better way to do it?</p>