title: Have Matlab type a string as if from keyboard
body: <p>I was wondering if anyone knew if it is possible to have MATLAB type a string for you, as if the user had typed it on the keyboard. I believe it can be done using a shell script or an applescript, but I was wondering if Matlab had a native implementation. </p>
  
  <p>I have tried searching around for it, but have not had any luck. It is not super necessary, but I am just super lazy and want to write a script that will automatically enter information into an application after MATLAB has calculated stuff. </p>
  
  <p>If you know of another simple way of doing this, let me know as well. Thanks a lot!</p>
  
  <p><strong>EDIT:</strong>
  Adding some code that I used in response to an answer below, using the Java Robot Class</p>
  
  <pre><code>function robotType(text)
      import java.awt.Robot; 
      import java.awt.event.*; 
      SimKey=Robot;
      for i = 1:length(text)
          if strcmp(text(i),upper(text(i))) == 0 || all(ismember(text(i),'0123456789')) == 1
              eval(['SimKey.keyPress(KeyEvent.VK_',upper(text(i)),')'])
              eval(['SimKey.keyRelease(KeyEvent.VK_',upper(text(i)),')'])
          else
              SimKey.keyPress(KeyEvent.VK_SHIFT);
              eval(['SimKey.keyPress(KeyEvent.VK_',upper(text(i)),')'])
              eval(['SimKey.keyRelease(KeyEvent.VK_',upper(text(i)),')'])
              SimKey.keyRelease(KeyEvent.VK_SHIFT);
          end
      end
  end
  </code></pre>
  
  <p>Warning, code may not be the best, but hey it was written in like 5 minutes.</p>