Integrate Simulink models with C or C++

(Last Updated On: September 4, 2015)
Learn the Secret

Get  our 2 Free Books

Get these now which land directly to their inbox.
Invalid email address

Integrate Simulink models with C or C+++

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

More complicated:

More compicated:


This appears to work best:

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:


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!
This entry was posted in Matlab and tagged , , , on by .

About caustic

Hi i there My name is Bryan Downing. I am part of a company called QuantLabs.Net This is specifically a company with a high profile blog about technology, trading, financial, investment, quant, etc. It posts things on how to do job interviews with large companies like Morgan Stanley, Bloomberg, Citibank, and IBM. It also posts different unique tips and tricks on Java, C++, or C programming. It posts about different techniques in learning about Matlab and building models or strategies. There is a lot here if you are into venturing into the financial world like quant or technical analysis. It also discusses the future generation of trading and programming Specialties: C++, Java, C#, Matlab, quant, models, strategies, technical analysis, linux, windows P.S. I have been known to be the worst typist. Do not be offended by it as I like to bang stuff out and put priorty of what I do over typing. Maybe one day I can get a full time copy editor to help out. Do note I prefer videos as they are much easier to produce so check out my many video at