필터 지우기
필터 지우기

Using C# codes in Matlab functions

조회 수: 26 (최근 30일)
Milad Bahaedini
Milad Bahaedini 2022년 6월 27일
답변: Rishav 2023년 9월 7일
Hi everyone. I have some complex C# codes and I want to use them as Matlab functions to simulate a model in Simulink. I have searched a lot in Internet but couldn't find a way to implement C# codes in Matlab. Can anyone help?
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 6월 27일
You might be able to do something if there is a C compatibility mode like C++ has, but there is no support for calling into C# methods

댓글을 달려면 로그인하십시오.

답변 (1개)

Rishav
Rishav 2023년 9월 7일
Hi Milad,
As of now, there is no support for implementing C# codes in MATLAB.
MATLAB primarily supports its own scripting language, and while it has features for integrating external code and functions, such as MEX functions for C/C++ and .NET assembly integration.
Here are some workarounds you can consider:
  1. C# to .NET Assembly: One way to integrate C# code into MATLAB is by converting your C# code into a .NET assembly (DLL). You can create a .NET assembly from your C# code using Visual Studio or a similar tool. Once you have the assembly, you can use MATLAB's .NET support to load and call functions from the assembly.
Please refer to the below mentioned documentation for the same:
2. MATLAB External Interface: You can create a standalone application in C# that communicates with MATLAB via the MATLAB Engine API for .NET. This way, your C# application can send data to MATLAB, execute MATLAB scripts/functions, and receive results.
Please refer to the below mentioned documentation for the same:

카테고리

Help CenterFile Exchange에서 Getting Started with Microsoft .NET에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by