fbpx

Integrate Simulink models with C or C++

(Last Updated On: September 4, 2015)

Integrate Simulink models with C or C+++

Some interesting examples to integrate Simulink models with C or C++

http://www.mathworks.com/examples/search?q=c+code

http://www.mathworks.com/examples/simulink-coder/11956-integrate-external-c-code-into-a-model-using-stateflow

http://www.mathworks.com/examples/simulink-coder/11919-integrate-external-c-code-into-generated-code-using-custom-code-blocks-and-model-configuration-parameters

More complicated: http://www.mathworks.com/examples/embedded-coder/12288-call-external-c-code-from-model-and-generated-code

More compicated:  http://www.mathworks.com/help/ecoder/examples/calling-external-c-code-from-the-simulink-model-and-generated-code.html#ecoder-ex36862053

 

This appears to work best:

http://www.mathworks.com/examples/simulink-coder/11956-integrate-external-c-code-into-a-model-using-stateflow

Works in a writeable directory like C:\Users\Bryan\Documents\MATLAB\simulink\Integrate External Cpp

For C run command to load Simulink under Code tab: http://www.mathworks.com/examples/search?q=c+code

 

For proper configuration for C++ (rtwdemo_sfcpp) under Code Generation -> Custom Code settings

Source file: ¬†#include “adder_cpp.h”

Header file: blank

Initialize function:  adderVar = createAdder();

Teminate Function:  deleteAdder(adderVar);

Include directories: ¬†“$matlabroot$/toolbox/rtw/rtwdemos/custom_cpp_src”

Source files: ¬†“$matlabroot$/toolbox/rtw/rtwdemos/custom_cpp_src/adder_cpp.cpp”

Libraries: blank

Listed below is a 4 segments containing:

Example walkthru of Simulink integration with C++

Integrate Simulink models with C

Integrate Simulink models with C code generation

Integrate Simulink models with C or Cpp

Demo of Simulink call C in Ubuntu Linux

In conclusion, I don’t think this is a solid path at this point. due to inexperience I think. It might be best to handcode the Redis functionality around the code generated Simulink model. This sort of sucks but I tried.

NOTE the source files are available for any Quant Elite members to see if they get it working

Join my FREE newsletter to learn more about how I accomplish this hand coding with Redis and the trading model (I already done that remember?)

 

This is what I will have to end up doing:

 

 

 

 

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Subscribe For Latest Updates

Sign up to best of business news, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.
Scroll to Top