title: MatlabGUI How to create Buttons dynamically and recognize that the Button was pushed
body: <p>I am working on a GUI to control a Oscilloscope. Due to the problem that not all Oscilloscopes have the same number of channels I have to create some buttons dynamically. I can create the buttons but I don't know how to recognize that the button was clicked.</p>
  
  <p>I have to do the same thing with some textinputfields.</p>
  
  <p>At the moment, I can create the buttons dynamically, but don't know how to get the data.</p>
  
  <pre><code>classdef GUIcontrol &lt; handle
      properties
          figure
          button = {};
      end   
      methods 
          function obj = GUIcontrol()
            %create figure for 'GUIcontrol'
             obj.figure=figure
             position=[20 20 80 20];
            for n= 1:4
                obj.button{n}=createButton(obj, position);
                position(1)=position(1)+120;
            end
  
  
          end
  
          function button= createButton(handle, position)
  
            %create a pushbutton UI
  
            button = uicontrol('Style', 'pushbutton',....
                               'string', 'unknownYet',...
                               'units', 'pixels',...
                               'Position',position,...
                               'callback', @eg_fun);  
          end
      end
  end
  </code></pre>