ha9u63a7
ha9u63a7

Reputation: 6824

C/C++ Wrapper for SIMULINK models

I have a very big C/C++ software project in Visual Studio and Eclipse. There are some third party software in the form of SIMULINK models. Is it currently possible to:

1) Write C/C++ wrapper functions for SIMULINK models? 2) Invoke the functions from external environment such as VS or Eclipse C/C++ projects to perform integration and further tasks?

I know that you can use MEX (MATLAB Exec.) functions which are C/C++ or FORTRAN wrapped for MATLAB usage. But this is not ideal for me.

USE CASE

My use case is based on modelling and simulation, but my subsystems are quite diverse in terms of data format. 50% is in C/C++, 35% is in SIMULINK models, and the rest are in binary executables, object code, symbol data, etc. I am doing some complex system modelling; Sorry, but cannot tell you further due to protective reasons.

From the answers I am getting, it seems people are keen to just use what Mathworks offers. My intention was to get more like a yes no answer, but so far I got good explanations too.

UPDATE

I will have to evaluate SIMULINK's embedded coder and see how much extra effort is required on polishing the generated code. I read that there is production-level code generation facility in Embedded Coder; should be interesting.

Upvotes: 1

Views: 5054

Answers (1)

Phil Goddard
Phil Goddard

Reputation: 10762

There are two choices depending on exactly what your requirements are:

  • convert the Simulink models to C using Simulink Coder. This effectively gets you out of the Simulink environment, so integrating the model functionality into you existing environment is identical to incorporating any other C code. Of course you need access to Simulink Coder to do this.

  • Calling the MATLAB Engine. Note you cannot call just Simulink. You call MATLAB and issue various MATLAB commands to load, execute, and interrogate the Simulink model.

Upvotes: 3

Related Questions