Is it possible to compile C# code in Matlab?

9 次查看(过去 30 天)
I'm currently working on the tool which consist of 2 parts. One is written outside in C#. Another will be developed in Matlab. The tool should run under Linux Red Hat 5.6 OS. It seems logical then to compile both parts using Matlab. But I can't find any infromation in help about compiling C# code. Still, I see articles about compiling C and C++ code.
Could anyone comment on the possiblity to compile C# code as well? I have currently 2010b version of Matlab.
Tnanks
  2 个评论
Friedrich
Friedrich 2012-3-27
C# and Linux? I would guess some C# clone, right?
The MEX concept works for C/C++ and Fortran only.
MATLAB cannot compile C# code. However you can use System commands from MATLAB to call the C# compiler.
If you want to use .NET DLL's in MATLAB one uses NET.addAssembly. But not sure if this command runs/is shipped on Linux.
Alexander
Alexander 2012-3-27
Friedrich,
Thank you for the answer. Obviously, I have to state the question more precise.
The tool should run under Linux environment. One part of the tool is written in C# in Windows (not by me). Another one will be written in Matlab. So, the question was if I can use Matlab to compile the first part under Linux.
If I understand you correctly, this is something which in general is not possible. Right?
Regards,
Alexander

请先登录,再进行评论。

采纳的回答

Friedrich
Friedrich 2012-3-27
Hi,
yes C# is Windows only. So it won't run on Linux. But there are some Linux clones available:
But I am not sure if this works nicely and if this works together with MATLAB. This would also require that the end user installs these files.
If possible, I would recommend rewriting the C# part in JAVA so that it can run on Linux and Windows (and also MAC).

更多回答(1 个)

Bill Chou
Bill Chou 2020-3-23
Another possible approach is to have the final program running in C# outside of MATLAB. In this case, you could use MATLAB Coder to convert your MATLAB algorithms into C/C++, do some manual work to interface it with C#, and then integrate that into your C# application. Please see this article for more details:

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler SDK 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by