title: Integrating Matlab Coder with c#
body: <p>I want to integrate MATLAB Coder output with a C# project in Visual Studio 2010. My main idea is:</p>
  
  <ul>
  <li>Create a *.m script in Matlab</li>
  <li>Make sure the script is compatible with Matlab Coder.</li>
  <li>Generate a C++ shared library (DLL) with Matlab Coder</li>
  <li><p>Integrate with C# using something like this:</p>
  
  <pre><code>//Starts the model execution. May take several minutes
  public static class DllHelper
  {
      [DllImport(@"test.dll",CallingConvention=CallingConvention.Cdecl,EntryPoint = "Run()")]
      public static extern int Run();
  }
  </code></pre></li>
  <li><p>Also, I would like to be able to stop the execution and retrieve some partial results. To do this, I was thinking in two methods: <code>StopExecution</code> and <code>RetrievePartialResults</code></p>
  
  <pre><code>[DllImport(@"test.dll",CallingConvention=CallingConvention.Cdecl,EntryPoint =     "StopExecution ()")]
  public static extern int StopExecution ();
  
  [DllImport(@"test.dll",CallingConvention=CallingConvention.Cdecl,EntryPoint = "RetrievePartialResults()")]
  public static extern MyResults RetrievePartialResults();
  </code></pre></li>
  </ul>
  
  <p>Is it possible to do? If no, is there any alternatives? If yes, where can I find more examples?</p>