title: How do I use Matlab engine in my code (for calling `engOpenSingleUse()`)?
body: <p>I'm trying to send simple string commands to the Matlab engine.</p>
  
  <p>This is my code (there is no Matlab API related code anywhere else in my code, except for the <code>#include "engine.h"</code> line):</p>
  
  <pre><code>void MatlabPlotter::DrawInMatlab() const
  {
      std::string PlotCommand = "x=[0 1 2 3 4 5];y=[0 1 4 9 16 25];plot(x, y);";
      void * vpDcom = NULL;
      int iReturnValue;
      engOpenSingleUse(PlotCommand.c_str(), vpDcom, &amp;iReturnValue);
  }
  </code></pre>
  
  <p>The code compiles and runs successfully without any compiler errors or run time error messages. The "Matlab Command Window" opens; I get a screen like below:</p>
  
  <p><img src="https://i.stack.imgur.com/U5vw8.png" alt="Empty Matlab Command Window"></p>
  
  <p>As you see, the command window is empty. There is no plotting window on the screen.<br>
  When I manually type the command into this window, I get the plotting without any error, like below:</p>
  
  <p><img src="https://i.stack.imgur.com/FNDRH.png" alt="Manually typed command to the command window"></p>
  
  <p>This is the official documentation page for the <code>engOpenSingleUse()</code> function:<br>
  <a href="http://www.mathworks.com/help/techdoc/apiref/engopensingleuse.html" rel="nofollow noreferrer">http://www.mathworks.com/help/techdoc/apiref/engopensingleuse.html</a></p>
  
  <p>I added <code>&lt;MatlabInstallationDir&gt;\extern\lib\win64\microsoft\libeng.lib</code> library in my project (I'm compiling in x64 debug configuration).<br>
  I included <code>&lt;MatlabInstallationDir&gt;\extern\include\engine.h</code> header file.<br>
  I typed <code>!matlab /regserver</code> command to the main Matlab window (as described in the documentation page of the <code>engOpenSingleUse()</code> function) to make sure Matlab engine is registered to my OS.</p>
  
  <p>Why doesn't anything happen when I call the <code>engOpenSingleUse()</code> function?<br>
  Why doesn't a plotting window pop up when I send the string command in the <code>PlotCommand</code> object to plot the plotting?<br>
  What am I doing wrong?</p>
  
  <p>OS: Windows 7 Ultimate x64 SP1, up-to-date<br>
  IDE: Visual Studio 2010, (Version 10.0.40219.1 SP1Rel)<br>
  Matlab: 7.8.0 (R2009a)</p>