![matlab 2017 a reference matlab 2017 a reference](https://www.theengineeringprojects.com/wp-content/uploads/2017/05/8-2.png)
When it will try to create another Matlab, it will just return a reference to the same object. Program Id " " means single Matlab COM server for our application.
Matlab 2017 a reference Activator#
This code will create a single Matlab COM server through Activator class.
![matlab 2017 a reference matlab 2017 a reference](http://141.89.112.21/wp-content/uploads/2017/05/IMG_8813.jpg)
Var matlab = (MLApp.MLApp)Activator.CreateInstance(activationContext) Ĭonsole.WriteLine(matlab.Execute( " 1+2")) To do that, we can add code to our main program:Ĭopy Code var activationContext = Type.GetTypeFromProgID( " ") In order to use it, we should create our Matlab server from C# application. You should get a new reference like below: Then choose "Matlab Application (Version 7.10) Type Library". First, we will add DLL reference with COM interface. Let's start with a simple console application.
![matlab 2017 a reference matlab 2017 a reference](https://i.ytimg.com/vi/JIh_rE1IcQc/maxresdefault.jpg)
it was only a test so there might be other problems that I am not aware of. I also tried with 7.1 and (if I remember correctly) it required only to swap reference in Visual Studio. Since interface for communicating with Matlab server is dependent on installed Matlab version and registry entries, it may have been different from yours. But I had only this version at my disposal. Important: I was using R2010a version of Matlab. Nonetheless, I accomplished why I was required to do, so I decided to share this with the rest of the world. I guess writing programs that use Matlab for calculating is not encouraged by MathWorks, you would became competition that way. I have found it hard to use it mainly due to lack of documentation, which is really basic with only few code examples for C#. While writing an application for my Masters degree diploma, I wrote a simple application that was using COM Matlab server.