フィルターのクリア

How to convert C++ simulations to Simulink?

9 ビュー (過去 30 日間)
Sanchito
Sanchito 2013 年 10 月 9 日
回答済み: Kaustubha Govind 2013 年 10 月 11 日
Hello,
so I have a 6DOF simulation of an aircraft. There are a few header files eg: 1. class_heirarchy.hpp -> three classes (base class, one instance of inherited class, the second inheritance of a derive class) 2. global constants.hpp 3. global_header.hpp 4. utility_header.hpp
and in the source files i have the actual simlation wherein i have the following cpp files: kinematics.cpp environment.cpp aerodynamics.cpp propulsion.cpp ins.cpp control.cpp actuator.cpp forces.cpp newton.cpp euler.cpp execution.cpp in each of these .cpp files there is a _def() function (defines the variables that are part of that module), a _init() function that initialises the values at the start of the simulation and then the actual function/functions that actually run when the simulation is going on. so the def and the init functions only get called once at the start of the simulation.
so now i have implemented my baseline controller in C++. what i need to do now is implement an adaptive controller. I would like to do this in MATLAB/SIMULINK. Is there an easy way (i understand its not particularly easy) but i mean an understandable way to get my 6DOF simulation into MATLAB so that i dont need to reimplement the whole model. I hope i have made my question clear.
No need to dumb it down .... I have looked at mex and all that .. and havent really understood what is going on there ..
Thanks and regards,
Sanchito

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2013 年 10 月 11 日
To bring C++ code into Simulink, you need to create a C-MEX S-function wrapper so that it can be used like any other S-function block in a model. Please see Integrate C Functions Using Legacy Code Tool to automatically generate the C-MEX S-function wrapper.

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by